[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5300 - in GNUnet/src: applications/transport include serve
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5300 - in GNUnet/src: applications/transport include server transports |
Date: |
Wed, 11 Jul 2007 03:31:35 -0600 (MDT) |
Author: grothoff
Date: 2007-07-11 03:31:35 -0600 (Wed, 11 Jul 2007)
New Revision: 5300
Modified:
GNUnet/src/applications/transport/transport.c
GNUnet/src/include/gnunet_core.h
GNUnet/src/include/gnunet_transport.h
GNUnet/src/server/connection.c
GNUnet/src/server/connection.h
GNUnet/src/server/core.c
GNUnet/src/server/handler.c
GNUnet/src/transports/tcp_helper.c
Log:
extra checks
Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c 2007-07-11 09:22:12 UTC
(rev 5299)
+++ GNUnet/src/applications/transport/transport.c 2007-07-11 09:31:35 UTC
(rev 5300)
@@ -643,6 +643,7 @@
ctapi.receive = NULL; /* initialized LATER! */
ctapi.requestService = coreAPI->requestService;
ctapi.releaseService = coreAPI->releaseService;
+ ctapi.assertUnused = coreAPI->assertUnused;
GROW (tapis, tapis_count, UDP_PROTOCOL_NUMBER + 1);
Modified: GNUnet/src/include/gnunet_core.h
===================================================================
--- GNUnet/src/include/gnunet_core.h 2007-07-11 09:22:12 UTC (rev 5299)
+++ GNUnet/src/include/gnunet_core.h 2007-07-11 09:31:35 UTC (rev 5300)
@@ -624,6 +624,9 @@
struct GE_Context *(*createClientLogContext) (GE_KIND mask,
struct ClientHandle * handle);
+
+ int (*assertUnused)(TSession * tsession);
+
} CoreAPIForApplication;
Modified: GNUnet/src/include/gnunet_transport.h
===================================================================
--- GNUnet/src/include/gnunet_transport.h 2007-07-11 09:22:12 UTC (rev
5299)
+++ GNUnet/src/include/gnunet_transport.h 2007-07-11 09:31:35 UTC (rev
5300)
@@ -158,6 +158,9 @@
*/
int (*releaseService) (void *service);
+ int (*assertUnused)(TSession * tsession);
+
+
} CoreAPIForTransport;
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2007-07-11 09:22:12 UTC (rev 5299)
+++ GNUnet/src/server/connection.c 2007-07-11 09:31:35 UTC (rev 5300)
@@ -3822,7 +3822,34 @@
+/**
+ * Verify that the given session handle is not in use.
+ * @return OK if that is true, SYSERR if not.
+ */
+int assertUnused(TSession * tsession) {
+ int i;
+ BufferEntry * root;
+ MUTEX_LOCK (lock);
+ for (i = 0; i < CONNECTION_MAX_HOSTS_; i++)
+ {
+ root = CONNECTION_buffer_[i];
+ while (NULL != root)
+ {
+ if (root->session.tsession == tsession) {
+ GE_BREAK(ectx, 0);
+ MUTEX_UNLOCK (lock);
+ return SYSERR;
+ }
+ root = root->overflowChain;
+ }
+ }
+ MUTEX_UNLOCK (lock);
+
+ return OK;
+}
+
+
void __attribute__ ((constructor)) gnunet_connection_ltdl_init ()
{
lock = MUTEX_CREATE (YES);
Modified: GNUnet/src/server/connection.h
===================================================================
--- GNUnet/src/server/connection.h 2007-07-11 09:22:12 UTC (rev 5299)
+++ GNUnet/src/server/connection.h 2007-07-11 09:31:35 UTC (rev 5300)
@@ -260,7 +260,7 @@
* Get the current number of slots in the connection table (as computed
* from the available bandwidth).
*/
-int getSlotCount ();
+int getSlotCount (void);
/**
* Is the given slot used?
@@ -306,7 +306,11 @@
*/
int unregisterSendNotify (MessagePartHandler callback);
+/**
+ * Verify that the given session handle is not in use.
+ * @return OK if that is true, SYSERR if not.
+ */
+int assertUnused(TSession * tsession);
-
#endif
/* end of connection.h */
Modified: GNUnet/src/server/core.c
===================================================================
--- GNUnet/src/server/core.c 2007-07-11 09:22:12 UTC (rev 5299)
+++ GNUnet/src/server/core.c 2007-07-11 09:31:35 UTC (rev 5300)
@@ -554,6 +554,7 @@
applicationCore.getSlotCount = &getSlotCount; /* connection.c */
applicationCore.isSlotUsed = &isSlotUsed; /* connection.c */
applicationCore.getLastActivityOf = &getLastActivityOf; /*
connection.c */
+ applicationCore.assertUnused = &assertUnused; /* connection.c */
applicationCore.sendErrorMessageToClient = &sendTCPErrorToClient; /*
tcpserver.c */
applicationCore.createClientLogContext = &createClientLogContext; /*
tcpserver.c */
Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2007-07-11 09:22:12 UTC (rev 5299)
+++ GNUnet/src/server/handler.c 2007-07-11 09:31:35 UTC (rev 5300)
@@ -702,7 +702,8 @@
return;
}
/* try to increment session reference count */
- if (SYSERR == transport->associate (mp->tsession))
+ if ( (mp->tsession != NULL) &&
+ (SYSERR == transport->associate (mp->tsession)) )
mp->tsession = NULL;
MUTEX_LOCK (globalLock_);
Modified: GNUnet/src/transports/tcp_helper.c
===================================================================
--- GNUnet/src/transports/tcp_helper.c 2007-07-11 09:22:12 UTC (rev 5299)
+++ GNUnet/src/transports/tcp_helper.c 2007-07-11 09:31:35 UTC (rev 5300)
@@ -158,12 +158,24 @@
tcpsession->users--;
if ((tcpsession->users > 0) || (tcpsession->in_select == YES))
{
- if (tcpsession->users == 0)
+ if (tcpsession->users == 0) {
select_change_timeout (selector, tcpsession->sock, TCP_FAST_TIMEOUT);
+ GE_BREAK(ectx,
+ OK == coreAPI->assertUnused(tsession));
+ }
MUTEX_UNLOCK (tcpsession->lock);
MUTEX_UNLOCK (tcplock);
return OK;
}
+ if (OK != coreAPI->assertUnused(tsession)) {
+ GE_BREAK(ectx, 0);
+ abort(); /* for now */
+ /* recovery attempt */
+ tcpsession->users = 1;
+ MUTEX_UNLOCK (tcpsession->lock);
+ MUTEX_UNLOCK (tcplock);
+ return OK;
+ }
#if DEBUG_TCP
GE_LOG (ectx,
GE_DEBUG | GE_USER | GE_BULK,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5300 - in GNUnet/src: applications/transport include server transports,
gnunet <=