gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3996 - in GNUnet/src: applications/fs/ecrs applications/fs


From: grothoff
Subject: [GNUnet-SVN] r3996 - in GNUnet/src: applications/fs/ecrs applications/fs/fsui applications/fs/lib util/error util/network_client
Date: Thu, 21 Dec 2006 14:29:00 -0800 (PST)

Author: grothoff
Date: 2006-12-21 14:28:55 -0800 (Thu, 21 Dec 2006)
New Revision: 3996

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/fsui/serializetest4.c
   GNUnet/src/applications/fs/lib/fslib.c
   GNUnet/src/util/error/error.c
   GNUnet/src/util/network_client/tcpio.c
Log:
better error handling

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2006-12-21 22:09:37 UTC (rev 
3995)
+++ GNUnet/src/applications/fs/ecrs/download.c  2006-12-21 22:28:55 UTC (rev 
3996)
@@ -430,6 +430,13 @@
   RequestManager * rm;
 
   rm = MALLOC(sizeof(RequestManager));
+  rm->sctx = FS_SEARCH_makeContext(ectx,
+                                  cfg,
+                                  rm->lock);
+  if (rm->sctx == NULL) {
+    FREE(rm);
+    return NULL;
+  }
   rm->ectx
     = ectx;
   rm->cfg
@@ -442,9 +449,6 @@
     = 0;
   rm->lock
     = MUTEX_CREATE(YES);
-  rm->sctx = FS_SEARCH_makeContext(ectx,
-                                  cfg,
-                                  rm->lock);
   rm->requestListIndex
     = 0;
   rm->requestListSize
@@ -1336,6 +1340,11 @@
   }
   rm = createRequestManager(ectx,
                            cfg);
+  if (rm == NULL) {
+    freeIOC(&ioc, YES);
+    FREE(realFN);
+    return SYSERR;
+  }
   ctx.startTime = get_time();
   ctx.anonymityLevel = anonymityLevel;
   ctx.TTL_DECREMENT = 5 * cronSECONDS; /* HACK! */

Modified: GNUnet/src/applications/fs/fsui/serializetest4.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest4.c    2006-12-21 22:09:37 UTC 
(rev 3995)
+++ GNUnet/src/applications/fs/fsui/serializetest4.c    2006-12-21 22:28:55 UTC 
(rev 3996)
@@ -409,7 +409,7 @@
   }
   FSUI_stopDownload(ctx,
                    download);
-  for (j=4;j<256;j+=4) {
+  for (j=4;j<16;j+=4) {
     fn = makeName(j);
     unindex = FSUI_startUnindex(ctx, fn);
     FSUI_stopUnindex(ctx,

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2006-12-21 22:09:37 UTC (rev 
3995)
+++ GNUnet/src/applications/fs/lib/fslib.c      2006-12-21 22:28:55 UTC (rev 
3996)
@@ -158,13 +158,17 @@
   ret->cfg = cfg;
   ret->lock = lock;
   ret->sock = client_connection_create(ectx, cfg);
+  if (ret->sock == NULL) {
+    FREE(ret);
+    return NULL;
+  }
   ret->handles = NULL;
   ret->handleCount = 0;
   ret->handleSize = 0;
   ret->abort = NO;
   ret->thread = PTHREAD_CREATE(&processReplies,
                               ret,
-                              1028 * 1024);
+                              128 * 1024);
   if (ret->thread == NULL)
     GE_DIE_STRERROR(ectx,
                    GE_FATAL | GE_ADMIN | GE_BULK,
@@ -175,6 +179,7 @@
 void FS_SEARCH_destroyContext(struct FS_SEARCH_CONTEXT * ctx) {
   void * unused;
 
+  MUTEX_LOCK(ctx->lock);
   GE_ASSERT(ctx->ectx,
            ctx->handleCount == 0);
   ctx->abort = YES;
@@ -182,6 +187,7 @@
   PTHREAD_STOP_SLEEP(ctx->thread);
   PTHREAD_JOIN(ctx->thread,
               &unused);
+  MUTEX_UNLOCK(ctx->lock);
   ctx->lock = NULL;
   connection_destroy(ctx->sock);
   GROW(ctx->handles,
@@ -255,6 +261,7 @@
         &enc,
         type);
 #endif
+  GE_ASSERT(NULL, ctx->sock != NULL);
   if (OK != connection_write(ctx->sock,
                             &req->header)) {
     FS_stop_search(ctx,
@@ -284,6 +291,7 @@
         handle);
 #endif
   handle->req->header.type = htons(CS_PROTO_gap_QUERY_STOP);
+  GE_ASSERT(NULL, ctx->sock != NULL);
   connection_write(ctx->sock,
                   &handle->req->header);
   MUTEX_LOCK(ctx->lock);
@@ -381,8 +389,9 @@
   memcpy(&ri[1], fn, fnSize);
 
 #if DEBUG_FSLIB
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "Sending index initialization request to gnunetd\n");
+  GE_LOG(ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "Sending index initialization request to gnunetd\n");
 #endif
   if (OK != connection_write(sock,
         &ri->header)) {
@@ -391,11 +400,12 @@
   }
   FREE(ri);
 #if DEBUG_FSLIB
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "Waiting for confirmation of index initialization request by gnunetd\n");
+  GE_LOG(ectx,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "Waiting for confirmation of index initialization request by 
gnunetd\n");
 #endif
   if (OK != connection_read_result(sock,
-        &ret))
+                                  &ret))
     return SYSERR;
   return ret;
 }

Modified: GNUnet/src/util/error/error.c
===================================================================
--- GNUnet/src/util/error/error.c       2006-12-21 22:09:37 UTC (rev 3995)
+++ GNUnet/src/util/error/error.c       2006-12-21 22:28:55 UTC (rev 3996)
@@ -79,6 +79,10 @@
   if ( (ctx != NULL)  &&
        (! GE_applies(kind, ctx->mask)) )
     return;
+  if ( (ctx == NULL) &&
+       ( ((kind & (GE_IMMEDIATE | GE_BULK)) == 0) ||
+        ((kind & (GE_FATAL | GE_ERROR | GE_WARNING)) == 0) ) )
+    return;
   va_start(va, message);
   size = VSNPRINTF(NULL, 0, message, va) + 1;
   va_end(va);

Modified: GNUnet/src/util/network_client/tcpio.c
===================================================================
--- GNUnet/src/util/network_client/tcpio.c      2006-12-21 22:09:37 UTC (rev 
3995)
+++ GNUnet/src/util/network_client/tcpio.c      2006-12-21 22:28:55 UTC (rev 
3996)
@@ -137,6 +137,7 @@
 }
 
 void connection_close_temporarily(struct ClientServerConnection * sock) {
+  GE_ASSERT(NULL, sock != NULL);
   MUTEX_LOCK(sock->destroylock);
   if (sock->sock != NULL) {
     socket_close(sock->sock);
@@ -151,6 +152,7 @@
 }
 
 void connection_close_forever(struct ClientServerConnection * sock) {
+  GE_ASSERT(NULL, sock != NULL);
   MUTEX_LOCK(sock->destroylock);
   if (sock->sock != NULL) {
     socket_close(sock->sock);
@@ -168,6 +170,7 @@
 }
 
 void connection_destroy(struct ClientServerConnection * sock) {
+  GE_ASSERT(NULL, sock != NULL);
   connection_close_forever(sock);
   MUTEX_DESTROY(sock->readlock);
   MUTEX_DESTROY(sock->writelock);
@@ -194,6 +197,7 @@
   char * host;
   IPaddr ip;
 
+  GE_ASSERT(NULL, sock != NULL);
   if (sock->sock != NULL)
     return OK;
   if (sock->dead == YES)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]