cIndex = *conn_index;
assert(ctx->connections->connOpened);
-// assert(cIndex < ctx->connections->connOpened); // Assertion no longer valid. "Holes" in the pool are permitted.
edg_wll_gss_close(&ctx->connections->connPool[cIndex].gss, &ctx->p_tmp_timeout);
if (ctx->connections->connPool[cIndex].gsiCred)
memset(ctx->connections->connPool + cIndex, 0, sizeof(edg_wll_ConnPool));
- /* if deleted conn was not the last one -> there is a 'hole' and then */
- /* 'shake' together connections in pool, no holes are allowed */
- /* */
- /* This principle is unsuitable for multi-threaded applications. Too much waiting for connections */
- /* to unlock. We need to allow "holes" in the pool. */
-
-/* if (cIndex < ctx->connections->connOpened - 1) {
- ctx->connections->connPool[cIndex] = ctx->connections->connPool[ctx->connections->connOpened - 1];
- memset(ctx->connections->connPool + ctx->connections->connOpened - 1 , 0, sizeof(edg_wll_ConnPool));
- }*/
-
ctx->connections->connOpened--;
*conn_index = cIndex;
CloseConnection(ctx, &index);
}
else { /* free the oldest (unlocked) connection */
-/* assert(ctx->connections->connPool[0].peerName); // Full pool expected - accept non-NULL values only
- min = ctx->connections->connPool[0].lastUsed.tv_sec;*/
for (i=0; i<ctx->connections->poolSize; i++) {
assert(ctx->connections->connPool[i].peerName); // Full pool expected - accept non-NULL values only
if (!edg_wll_connectionTryLock(ctx, i)) {
}
}
}
-// printf("Connections to drop: %d\nDropping connection No. %d\n",foundConnToDrop,index);
if (!foundConnToDrop) return edg_wll_SetError(ctx,EAGAIN,"all connections in the connection pool are locked");
CloseConnection(ctx, &index);
}
assert(connToUse >= 0);
gettimeofday(&ctx->connections->connPool[connToUse].lastUsed, NULL);
-// sleep(3); //Just for testing
-
edg_wll_connectionUnlock(ctx, connToUse);
return 0;
extern "C" {
#endif
-#define EDG_WLL_CONNPOOL_DEBUG
-
#ifndef EDG_WLL_CONNPOOL_DECLARED
#define EDG_WLL_CONNPOOL_DECLARED 1
in case memory has been already allocated, just return a pointer */
edg_wll_Connections* edg_wll_initConnections();
-
-/** Set parameters */
-
-/* Not yet defined */
-
-/** Make connection (+ establish a lock) */
-
-/* Not yet defined */
-
-/** Unlock connection after use */
-
-/* Not yet defined */
-
-/** Forcibly drop the connection */
-
-/* Not yet defined */
-
-
-
#ifdef __cplusplus
}
#endif
-/* typedef struct _edg_wll_ConnPool { */
-/* address and port where we are connected to */
-/* char *peerName; */
-/* unsigned int peerPort; */
-
- /* http(s) stream */
-/* gss_cred_id_t gsiCred; */
-/* edg_wll_GssConnection gss; */
-/* char *buf; */
-/* int bufUse,bufSize; */
-
-/* timestamp of usage of this entry in ctx.connPool */
-/* struct timeval lastUsed; */
-/* } edg_wll_ConnPool; */
-
-
-
struct _edg_wll_Context {
/* Error handling */
int errCode; /* recent error code */
char *srvName;
unsigned int srvPort;
-/* pool of connections from client */
-// int poolSize;
-// int connOpened; /* number of opened connections */
-// int connToUse; /* index of connection that will *
-// * be used by low-level f-cions */
- // XXX similar variables will be needed for connPoolNotif
-
-
/* other client stuff */
int notifSock; /* default client socket *
* for receiving notifications */