[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3582 - in GNUnet/src: applications/dht/tools applications/
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3582 - in GNUnet/src: applications/dht/tools applications/fs/fsui applications/fs/lib applications/template applications/tracekit applications/vpn include util/network_client |
Date: |
Tue, 31 Oct 2006 18:57:31 -0800 (PST) |
Author: grothoff
Date: 2006-10-31 18:57:20 -0800 (Tue, 31 Oct 2006)
New Revision: 3582
Modified:
GNUnet/src/applications/dht/tools/dht_api.c
GNUnet/src/applications/fs/fsui/Makefile.am
GNUnet/src/applications/fs/fsui/downloadtest.c
GNUnet/src/applications/fs/fsui/search.c
GNUnet/src/applications/fs/lib/fslib.c
GNUnet/src/applications/template/gnunet-template.c
GNUnet/src/applications/tracekit/gnunet-tracekit.c
GNUnet/src/applications/vpn/gnunet-vpn.c
GNUnet/src/include/gnunet_util_network_client.h
GNUnet/src/util/network_client/tcpio.c
GNUnet/src/util/network_client/tcpiotest.c
Log:
fixing potential shutdown deadlock and bad pthread join for completed, resumed
searches
Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2006-10-30 20:39:55 UTC (rev
3581)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2006-11-01 02:57:20 UTC (rev
3582)
@@ -585,7 +585,7 @@
}
MUTEX_LOCK(list->lock);
if (list->sock != NULL)
- connection_close_temporarily(list->sock); /* signal process_thread */
+ connection_close_forever(list->sock); /* signal process_thread */
MUTEX_UNLOCK(list->lock);
unused = NULL;
PTHREAD_JOIN(list->processor, &unused);
Modified: GNUnet/src/applications/fs/fsui/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/fsui/Makefile.am 2006-10-30 20:39:55 UTC (rev
3581)
+++ GNUnet/src/applications/fs/fsui/Makefile.am 2006-11-01 02:57:20 UTC (rev
3582)
@@ -38,6 +38,7 @@
fsuitest \
fsuitest2 \
searchtest \
+ serializetest \
downloadtest
TESTS = $(check_PROGRAMS)
@@ -78,3 +79,13 @@
$(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
$(top_builddir)/src/util/libgnunetutil.la
+
+serializetest_SOURCES = \
+ serializetest.c
+serializetest_LDADD = \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c 2006-10-30 20:39:55 UTC
(rev 3581)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c 2006-11-01 02:57:20 UTC
(rev 3582)
@@ -35,7 +35,7 @@
#include "gnunet_util_network_client.h"
#include "gnunet_util_crypto.h"
-#define DEBUG_VERBOSE NO
+#define DEBUG_VERBOSE YES
#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
@@ -213,7 +213,7 @@
#define FILESIZE (1024 * 1024 * 2)
-#define START_DAEMON 1
+#define START_DAEMON 0
int main(int argc, char * argv[]){
#if START_DAEMON
Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c 2006-10-30 20:39:55 UTC (rev
3581)
+++ GNUnet/src/applications/fs/fsui/search.c 2006-11-01 02:57:20 UTC (rev
3582)
@@ -387,8 +387,13 @@
prev->next = pos->next;
MUTEX_UNLOCK(ctx->lock);
pos->next = NULL;
- PTHREAD_JOIN(pos->handle,
- &unused);
+ if ( (pos->state == FSUI_COMPLETED) ||
+ (pos->state == FSUI_ABORTED) ||
+ (pos->state == FSUI_ERROR) ) {
+ PTHREAD_JOIN(pos->handle,
+ &unused);
+ pos->state++; /* add _JOINED */
+ }
event.type = FSUI_search_stopped;
event.data.SearchStopped.sc.pos = pos;
event.data.SearchStopped.sc.cctx = pos->cctx;
Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c 2006-10-30 20:39:55 UTC (rev
3581)
+++ GNUnet/src/applications/fs/lib/fslib.c 2006-11-01 02:57:20 UTC (rev
3582)
@@ -177,7 +177,7 @@
GE_ASSERT(ctx->ectx,
ctx->handleCount == 0);
ctx->abort = YES;
- connection_close_temporarily(ctx->sock);
+ connection_close_forever(ctx->sock);
PTHREAD_STOP_SLEEP(ctx->thread);
PTHREAD_JOIN(ctx->thread,
&unused);
Modified: GNUnet/src/applications/template/gnunet-template.c
===================================================================
--- GNUnet/src/applications/template/gnunet-template.c 2006-10-30 20:39:55 UTC
(rev 3581)
+++ GNUnet/src/applications/template/gnunet-template.c 2006-11-01 02:57:20 UTC
(rev 3582)
@@ -106,7 +106,7 @@
/* wait for shutdown... */
- connection_close_temporarily(sock);
+ connection_close_forever(sock);
SEMAPHORE_DOWN(doneSem, YES);
SEMAPHORE_DESTROY(doneSem);
PTHREAD_JOIN(messageReceiveThread, &unused);
Modified: GNUnet/src/applications/tracekit/gnunet-tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/gnunet-tracekit.c 2006-10-30 20:39:55 UTC
(rev 3581)
+++ GNUnet/src/applications/tracekit/gnunet-tracekit.c 2006-11-01 02:57:20 UTC
(rev 3582)
@@ -355,7 +355,7 @@
0,
NULL);
GNUNET_SHUTDOWN_WAITFOR();
- connection_close_temporarily(sock);
+ connection_close_forever(sock);
SEMAPHORE_DOWN(doneSem, YES);
SEMAPHORE_DESTROY(doneSem);
PTHREAD_JOIN(messageReceiveThread, &unused);
Modified: GNUnet/src/applications/vpn/gnunet-vpn.c
===================================================================
--- GNUnet/src/applications/vpn/gnunet-vpn.c 2006-10-30 20:39:55 UTC (rev
3581)
+++ GNUnet/src/applications/vpn/gnunet-vpn.c 2006-11-01 02:57:20 UTC (rev
3582)
@@ -242,7 +242,7 @@
}
/* we can't guarantee that this can be called while the other thread is
waiting for read */
- connection_close_temporarily(sock);
+ connection_close_forever(sock);
SEMAPHORE_DOWN(doneSem, YES);
SEMAPHORE_DESTROY(doneSem);
Modified: GNUnet/src/include/gnunet_util_network_client.h
===================================================================
--- GNUnet/src/include/gnunet_util_network_client.h 2006-10-30 20:39:55 UTC
(rev 3581)
+++ GNUnet/src/include/gnunet_util_network_client.h 2006-11-01 02:57:20 UTC
(rev 3582)
@@ -62,6 +62,15 @@
void connection_close_temporarily(struct ClientServerConnection * sock);
/**
+ * Close a GNUnet TCP socket forever.
+ * Prevent it from being opened again.
+ *
+ * Also, you must still call connection_destroy to free all
+ * resources associated with the connection.
+ */
+void connection_close_forever(struct ClientServerConnection * sock);
+
+/**
* Destroy connection between gnunetd and clients.
* Also closes the connection if it is still active.
*/
Modified: GNUnet/src/util/network_client/tcpio.c
===================================================================
--- GNUnet/src/util/network_client/tcpio.c 2006-10-30 20:39:55 UTC (rev
3581)
+++ GNUnet/src/util/network_client/tcpio.c 2006-11-01 02:57:20 UTC (rev
3582)
@@ -68,6 +68,8 @@
struct GC_Configuration * cfg;
+ int dead;
+
} ClientServerConnection;
@@ -148,8 +150,23 @@
MUTEX_UNLOCK(sock->destroylock);
}
+void connection_close_forever(struct ClientServerConnection * sock) {
+ MUTEX_LOCK(sock->destroylock);
+ if (sock->sock != NULL) {
+ socket_close(sock->sock);
+ MUTEX_LOCK(sock->readlock);
+ MUTEX_LOCK(sock->writelock);
+ socket_destroy(sock->sock);
+ sock->sock = NULL;
+ sock->dead = YES;
+ MUTEX_UNLOCK(sock->writelock);
+ MUTEX_UNLOCK(sock->readlock);
+ }
+ MUTEX_UNLOCK(sock->destroylock);
+}
+
void connection_destroy(struct ClientServerConnection * sock) {
- connection_close_temporarily(sock);
+ connection_close_forever(sock);
MUTEX_DESTROY(sock->readlock);
MUTEX_DESTROY(sock->writelock);
MUTEX_DESTROY(sock->destroylock);
@@ -177,6 +194,8 @@
if (sock->sock != NULL)
return OK;
+ if (sock->dead == YES)
+ return SYSERR;
port = getGNUnetPort(sock->ectx,
sock->cfg);
if (port == 0)
@@ -197,6 +216,11 @@
MUTEX_UNLOCK(sock->destroylock);
return OK;
}
+ if (sock->dead == YES) {
+ FREE(host);
+ MUTEX_UNLOCK(sock->destroylock);
+ return SYSERR;
+ }
osock = SOCKET(PF_INET, SOCK_STREAM, 6); /* 6: TCP */
if (osock == -1) {
GE_LOG_STRERROR(sock->ectx,
Modified: GNUnet/src/util/network_client/tcpiotest.c
===================================================================
--- GNUnet/src/util/network_client/tcpiotest.c 2006-10-30 20:39:55 UTC (rev
3581)
+++ GNUnet/src/util/network_client/tcpiotest.c 2006-11-01 02:57:20 UTC (rev
3582)
@@ -208,7 +208,7 @@
}
sh = socket_create(NULL, NULL, acceptSocket);
ret = ret | testTransmission(clientSocket, sh);
- connection_close_temporarily(clientSocket);
+ connection_close_forever(clientSocket);
socket_destroy(sh);
}
connection_destroy(clientSocket);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3582 - in GNUnet/src: applications/dht/tools applications/fs/fsui applications/fs/lib applications/template applications/tracekit applications/vpn include util/network_client,
grothoff <=