/*! * Send socket port that matches dpi_id to client */ void send_sockport(int sock_fd, char *dpi_tag, struct dp *dpi_attr_list) { int i; char *dpi_id, *d_cmd, port_str[16]; struct service *serv; dReturn_if_fail((dpi_id = get_message(sock_fd, dpi_tag)) != NULL); serv = dList_find_custom(services_list,dpi_id,(dCompareFunc)service_match); if (serv == NULL || (i = serv->dp_index) == -1) for (i = 0; i < numdpis; i++) if (!strncmp(dpi_attr_list[i].id, dpi_id, dpi_attr_list[i].id - strchr(dpi_attr_list[i].id, '.'))) break; if (i < numdpis) { /* found */ snprintf(port_str, 8, "%d", dpi_attr_list[i].port); d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s", "send_data", port_str); (void) CKD_WRITE(sock_fd, d_cmd); dFree(d_cmd); } dFree(dpi_id); }
/* * Remove a client from the queue */ static void Cache_client_dequeue(CacheClient_t *Client, int Key) { if (!Client) { Client = dList_find_custom(ClientQueue, INT2VOIDP(Key), Cache_client_by_key_cmp); } if (Client) { dList_remove(ClientQueue, Client); a_Web_free(Client->Web); dFree(Client); } }
/* * Last Client for this entry? * Return: Client if true, NULL otherwise * (cache.c has only one call to a capi function. This avoids a second one) */ CacheClient_t *a_Cache_client_get_if_unique(int Key) { int i, n = 0; CacheClient_t *Client, *iClient; if ((Client = dList_find_custom(ClientQueue, INT2VOIDP(Key), Cache_client_by_key_cmp))) { for (i = 0; (iClient = dList_nth_data(ClientQueue, i)); ++i) { if (iClient->Url == Client->Url) { ++n; } } } return (n == 1) ? Client : NULL; }
/* * Remove a client from the client queue * TODO: notify the dicache and upper layers */ void a_Cache_stop_client(int Key) { CacheClient_t *Client; CacheEntry_t *entry; DICacheEntry *DicEntry; /* The client can be in both queues at the same time */ if ((Client = dList_find_custom(ClientQueue, INT2VOIDP(Key), Cache_client_by_key_cmp))) { /* Dicache */ if ((DicEntry = a_Dicache_get_entry(Client->Url, Client->Version))) a_Dicache_unref(Client->Url, Client->Version); /* DelayedQueue */ if ((entry = Cache_entry_search(Client->Url))) dList_remove(DelayedQueue, entry); /* Main queue */ Cache_client_dequeue(Client, NULLKey); } else { _MSG("WARNING: Cache_stop_client, nonexistent client\n"); } }
/* * Find connection data by server */ static capi_conn_t *Capi_conn_find(char *server) { return dList_find_custom(CapiConns, (void*)server, Capi_conn_by_server_cmp); }