gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1823 - in GNUnet/src/applications: fs/module sqstore_mysql


From: grothoff
Subject: [GNUnet-SVN] r1823 - in GNUnet/src/applications: fs/module sqstore_mysql
Date: Sun, 21 Aug 2005 02:33:08 -0700 (PDT)

Author: grothoff
Date: 2005-08-21 02:33:06 -0700 (Sun, 21 Aug 2005)
New Revision: 1823

Modified:
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/applications/sqstore_mysql/mysql.c
Log:
stuff

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2005-08-21 04:21:19 UTC (rev 
1822)
+++ GNUnet/src/applications/fs/module/fs.c      2005-08-21 09:33:06 UTC (rev 
1823)
@@ -108,7 +108,9 @@
   HashCode512 hc;
   cron_t et;
   cron_t now;
+#if DEBUG_FS
   EncName enc;
+#endif
 
   if (ntohl(value->size) < sizeof(GapWrapper)) {
     BREAK();
@@ -122,9 +124,6 @@
                          (DBlock*)&gw[1],
                          &hc)) ||
        (! equalsHashCode512(&hc, query)) ) {
-    LOG(LOG_ERROR,
-       "Type: %u\n",
-       ntohl(*(unsigned int*) &gw[1]));
     BREAK(); /* value failed verification! */
     return SYSERR;
   }
@@ -157,12 +156,14 @@
     return SYSERR;
   }
   processResponse(query, dv);
+#if DEBUG_FS
   IFLOG(LOG_DEBUG,
        hash2enc(query,
                 &enc));
   LOG(LOG_DEBUG,
       "FS received GAP-PUT request (query: `%s')\n",
       &enc);
+#endif
   ret = datastore->putUpdate(query,
                             dv);
   FREE(dv);
@@ -172,6 +173,7 @@
 static int get_result_callback(const HashCode512 * query,
                               const DataContainer * value,
                               DHT_GET_CLS * cls) {
+#if DEBUG_FS
   EncName enc;
 
   IFLOG(LOG_DEBUG,
@@ -180,6 +182,7 @@
   LOG(LOG_DEBUG,
       "Found reply to query `%s'.\n",
       &enc);
+#endif
   gapPut(NULL,
         query,
         value,
@@ -206,19 +209,23 @@
                                     const CS_MESSAGE_HEADER * req) {
   const CS_fs_request_search_MESSAGE * rs;
   unsigned int keyCount;
+#if DEBUG_FS
   EncName enc;
+#endif
 
   if (ntohs(req->size) < sizeof(CS_fs_request_search_MESSAGE)) {
     BREAK();
     return SYSERR;
   }
   rs = (const CS_fs_request_search_MESSAGE*) req;
+#if DEBUG_FS
   IFLOG(LOG_DEBUG,
        hash2enc(&rs->query[0],
                 &enc));
   LOG(LOG_DEBUG,
       "FS received QUERY START (query: `%s')\n",
       &enc);
+#endif
   trackQuery(&rs->query[0],
             ntohl(rs->type),
             sock);
@@ -256,19 +263,23 @@
 static int csHandleRequestQueryStop(ClientHandle sock,
                                    const CS_MESSAGE_HEADER * req) {
   CS_fs_request_search_MESSAGE * rs;
+#if DEBUG_FS
   EncName enc;
+#endif
 
   if (ntohs(req->size) < sizeof(CS_fs_request_search_MESSAGE)) {
     BREAK();
     return SYSERR;
   }
   rs = (CS_fs_request_search_MESSAGE*) req;
+#if DEBUG_FS
   IFLOG(LOG_DEBUG,
        hash2enc(&rs->query[0],
                 &enc));
   LOG(LOG_DEBUG,
       "FS received QUERY STOP (query: `%s')\n",
       &enc);
+#endif
   if (ntohl(rs->anonymityLevel) == 0) {
     /* FIXME 0.7.1: cancel with dht? */
   }
@@ -291,7 +302,9 @@
   int ret;
   HashCode512 query;
   unsigned int type;
+#if DEBUG_FS
   EncName enc;
+#endif
 
   if (ntohs(req->size) < sizeof(CS_fs_request_insert_MESSAGE)) {
     BREAK();
@@ -312,15 +325,17 @@
     FREE(datum);
     return SYSERR;
   }
+  type = getTypeOfBlock(ntohs(ri->header.size) - 
sizeof(CS_fs_request_insert_MESSAGE),
+                       (const DBlock*) &ri[1]);
+#if DEBUG_FS
   IFLOG(LOG_DEBUG,
        hash2enc(&query,
                 &enc));
-  type = getTypeOfBlock(ntohs(ri->header.size) - 
sizeof(CS_fs_request_insert_MESSAGE),
-                       (const DBlock*) &ri[1]);
   LOG(LOG_DEBUG,
       "FS received REQUEST INSERT (query: `%s', type: %u)\n",
       &enc,
       type);
+#endif
   datum->type = htonl(type);
   memcpy(&datum[1],
         &ri[1],
@@ -401,10 +416,11 @@
           fn);
 
   FREE(fn);
-
+#if DEBUG_FS
   LOG(LOG_DEBUG,
       "Sending confirmation (%s) of index initialization request to client\n",
       ret == OK ? "success" : "failure");
+#endif
   return coreAPI->sendValueToClient(sock,
             ret);
 }
@@ -432,9 +448,11 @@
                       &ri->fileId,
                       ntohs(ri->header.size) - 
sizeof(CS_fs_request_index_MESSAGE),
                       (const DBlock*) &ri[1]);
+#if DEBUG_FS
   LOG(LOG_DEBUG,
       "Sending confirmation (%s) of index request to client\n",
       ret == OK ? "success" : "failure");
+#endif
   return coreAPI->sendValueToClient(sock,
                                    ret);
 }
@@ -454,17 +472,21 @@
        (0 != memcmp(&value[1],
                    &comp[1],
                    ntohl(value->size) - sizeof(Datastore_Value))) ) {
+#if DEBUG_FS
     LOG(LOG_DEBUG,
        "`%s' found value that does not match (%u, %u).\n",
        __FUNCTION__,
        ntohl(comp->size),
        ntohl(value->size));
+#endif
     return OK;
   }
   *comp = *value; /* make copy! */
+#if DEBUG_FS
   LOG(LOG_DEBUG,
       "`%s' found value that matches.\n",
       __FUNCTION__);
+#endif
   return SYSERR;
 }
 
@@ -480,7 +502,9 @@
   Datastore_Value * value;
   HashCode512 query;
   unsigned int type;
+#if DEBUG_FS
   EncName enc;
+#endif
 
   if (ntohs(req->size) < sizeof(CS_fs_request_delete_MESSAGE)) {
     BREAK();
@@ -504,6 +528,7 @@
     BREAK();
     return SYSERR;
   }
+#if DEBUG_FS
   IFLOG(LOG_DEBUG,
        hash2enc(&query,
                 &enc));
@@ -511,7 +536,7 @@
       "FS received REQUEST DELETE (query: `%s', type: %u)\n",
       &enc,
       type);
-
+#endif
   MUTEX_LOCK(&lock);
   if (SYSERR == datastore->get(&query,
                               type,
@@ -523,9 +548,11 @@
     ret = SYSERR;
   MUTEX_UNLOCK(&lock);
   FREE(value);
+#if DEBUG_FS
   LOG(LOG_DEBUG,
       "Sending confirmation (%s) of delete request to client\n",
       ret != SYSERR ? "success" : "failure");
+#endif
   return coreAPI->sendValueToClient(sock,
                                    ret);
 }
@@ -543,8 +570,10 @@
     return SYSERR;
   }
   ru = (CS_fs_request_unindex_MESSAGE*) req;
+#if DEBUG_FS
   LOG(LOG_DEBUG,
       "FS received REQUEST UNINDEX\n");
+#endif
   ret = ONDEMAND_unindex(datastore,
                         ntohl(ru->blocksize),
                         &ru->fileId);
@@ -566,8 +595,10 @@
     return SYSERR;
   }
   ru = (RequestTestindex*) req;
+#if DEBUG_FS
   LOG(LOG_DEBUG,
       "FS received REQUEST TESTINDEXED\n");
+#endif
   ret = ONDEMAND_testindexed(datastore,
                             &ru->fileId);
   return coreAPI->sendValueToClient(sock,
@@ -580,8 +611,10 @@
  */
 static int csHandleRequestGetAvgPriority(ClientHandle sock,
                                         const CS_MESSAGE_HEADER * req) {
+#if DEBUG_FS
   LOG(LOG_DEBUG,
       "FS received REQUEST GETAVGPRIORITY\n");
+#endif
   return coreAPI->sendValueToClient(sock,
                                    gap->getAvgPriority());
 }
@@ -616,13 +649,14 @@
   unsigned int level;
   EncName enc;
 
+#if DEBUG_FS
   IFLOG(LOG_DEBUG,
        hash2enc(key,
                 &enc));
   LOG(LOG_DEBUG,
       "Converting reply for query `%s' for gap.\n",
       &enc);
-
+#endif
   if (ntohl(invalue->type) == ONDEMAND_BLOCK) {
     if (OK != ONDEMAND_getIndexed(datastore,
                                  invalue,
@@ -726,6 +760,7 @@
                  void * resCallbackClosure) {
   int ret;
   GGC myClosure;
+#if DEBUG_FS
   EncName enc;
 
   IFLOG(LOG_DEBUG,
@@ -735,6 +770,7 @@
       "GAP requests content for `%s' of type %u\n",
       &enc,
       type);
+#endif
   myClosure.count = 0;
   myClosure.keyCount = keyCount;
   myClosure.keys = keys;

Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c       2005-08-21 04:21:19 UTC 
(rev 1822)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c       2005-08-21 09:33:06 UTC 
(rev 1823)
@@ -303,6 +303,16 @@
       dbhI->dbf = NULL;
       return SYSERR;
     }
+    mysql_query(dbhI->dbf,
+               "SET AUTOCOMMIT = 1");
+    if (mysql_error(dbhI->dbf)[0]) {
+      LOG_MYSQL(LOG_ERROR,
+               "mysql_query",
+               dbhI);
+      mysql_close(dbhI->dbf);
+      dbhI->dbf = NULL;
+      return SYSERR;
+    }
     
     dbhI->insert = mysql_stmt_init(dbhI->dbf);
     dbhI->select = mysql_stmt_init(dbhI->dbf);
@@ -654,11 +664,14 @@
   Datastore_Value * datum;
   HashCode512 key;
   unsigned long hashSize;
+#if DEBUG_MYSQL
   EncName enc;
+#endif
 
   if (query == NULL)
     return iterateLowPriority(type, iter, closure);
 
+#if DEBUG_MYSQL
   IFLOG(LOG_DEBUG,
        hash2enc(query,
                 &enc));
@@ -666,6 +679,7 @@
       "MySQL looks for `%s' of type %u\n",
       &enc,
       type);
+#endif
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
   if (type != 0) {
     if (iter == NULL)
@@ -802,6 +816,7 @@
   FREE(datum);
   MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
 
+#if DEBUG_MYSQL
   IFLOG(LOG_DEBUG,
        hash2enc(query,
                 &enc));
@@ -817,6 +832,7 @@
        &enc,
        type);
   }
+#endif
 
   return count;
 }
@@ -835,7 +851,9 @@
   unsigned int prio;
   unsigned int level;
   unsigned long long expiration;
+#if DEBUG_MYSQL
   EncName enc;
+#endif
 
   if ( (ntohl(value->size) < sizeof(Datastore_Value)) ) {
     BREAK();
@@ -852,6 +870,7 @@
   level = ntohl(value->anonymityLevel);
   expiration = ntohll(value->expirationTime);
 
+#if DEBUG_MYSQL
   IFLOG(LOG_DEBUG,
        hash2enc(key,
                 &enc));
@@ -859,6 +878,7 @@
       "Storing in database block with type %u and key %s.\n",
       type,
       &enc);
+#endif
   dbh->bind[0].buffer = (char*) &size;
   dbh->bind[1].buffer = (char*) &type;
   dbh->bind[2].buffer = (char*) &prio;
@@ -912,6 +932,7 @@
   unsigned int anon;
   unsigned long long expiration;
   unsigned long datasize;
+#if DEBUG_MYSQL
   EncName enc;
 
   IFLOG(LOG_DEBUG,
@@ -921,6 +942,7 @@
       "MySQL is executing deletion request for content of query `%s' and type 
%u\n",
       &enc,
       value == NULL ? 0 : ntohl(value->type));
+#endif
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
 
   twenty = sizeof(HashCode512);
@@ -970,9 +992,11 @@
   }
   count = mysql_stmt_affected_rows(stmt);
   MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+#if DEBUG_MYSQL
   LOG(LOG_DEBUG,
       "MySQL DELETE operation affected %d rows.\n",
       count);
+#endif
   return count;
 }
 





reply via email to

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