From: Manoj Kasichainula Date: Wed, 13 Oct 1999 22:40:09 +0000 (+0000) Subject: Add calls ap_get_connections and ap_get_connection_keys to the X-Git-Tag: 1.3.10~260 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=497fac3eb0fa1f2cb1df7d08c143c87657271055;p=apache Add calls ap_get_connections and ap_get_connection_keys to the connection status API, and add implementations of these calls to Dexter. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83992 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/mpm_status.h b/include/mpm_status.h index 899a619aab..ee6f50f6c6 100644 --- a/include/mpm_status.h +++ b/include/mpm_status.h @@ -80,6 +80,21 @@ typedef struct { */ API_EXPORT(const char *) ap_get_connection_status(long conn_id, const char *key); +/** + * Get an array of current connection IDs. + * + */ +API_EXPORT(ap_array_header_t *) ap_get_connections(ap_context_t *p); + +/** + * Get an array of keys from a given connection. + * + * conn_id = Connection ID + * + */ +API_EXPORT(ap_array_header_t *) ap_get_connection_keys(ap_context_t *p, + long conn_id); + /** * * Set a cell in the status table. No guarantees are made that long strings diff --git a/server/mpm/dexter/scoreboard.c b/server/mpm/dexter/scoreboard.c index e42bad0533..9b7dfd1997 100644 --- a/server/mpm/dexter/scoreboard.c +++ b/server/mpm/dexter/scoreboard.c @@ -483,6 +483,45 @@ const char *ap_get_connection_status(long conn_id, const char *key) return NULL; } +ap_array_header_t *ap_get_connections(ap_context_t *p) +{ + int i; + ap_array_header_t *connection_list; + long *array_slot; + + connection_list = ap_make_array(p, 0, sizeof(long)); + /* We assume that there is a connection iff it has an entry in the status + * table. Connections without any status sound problematic to me, so this + * is probably for the best. - manoj */ + for (i = 0; i < max_daemons_limit*HARD_THREAD_LIMIT; i++) { + if (ap_scoreboard_image->table[i][0].key[0] != '\0') { + array_slot = ap_push_array(connection_list); + *array_slot = i; + } + } + return connection_list; +} + +ap_array_header_t *ap_get_connection_keys(ap_context_t *p, long conn_id) +{ + int i = 0; + status_table_entry *ss; + ap_array_header_t *key_list; + char **array_slot; + + key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char)); + while (i < STATUSES_PER_CONNECTION) { + ss = &(ap_scoreboard_image->table[conn_id][i]); + if (ss->key[0] == '\0') { + break; + } + array_slot = ap_push_array(key_list); + *array_slot = ap_pstrdup(p, ss->key); + i++; + } + return key_list; +} + /* Note: no effort is made here to prevent multiple threads from messing with * a single connection at the same time. ap_update_connection_status should * only be called by the thread that owns the connection */