[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22158 - gnunet/src/lockmanager
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22158 - gnunet/src/lockmanager |
Date: |
Wed, 20 Jun 2012 16:24:45 +0200 |
Author: harsha
Date: 2012-06-20 16:24:45 +0200 (Wed, 20 Jun 2012)
New Revision: 22158
Modified:
gnunet/src/lockmanager/Makefile.am
gnunet/src/lockmanager/lockmanager_api.c
gnunet/src/lockmanager/test_lockmanager_api.c
Log:
-fixed reply handling
Modified: gnunet/src/lockmanager/Makefile.am
===================================================================
--- gnunet/src/lockmanager/Makefile.am 2012-06-20 14:18:02 UTC (rev 22157)
+++ gnunet/src/lockmanager/Makefile.am 2012-06-20 14:24:45 UTC (rev 22158)
@@ -55,6 +55,7 @@
test_lockmanager_api.c
test_lockmanager_api_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
libgnunetlockmanager.la
test_lockmanager_api_lockrelease_SOURCES = \
Modified: gnunet/src/lockmanager/lockmanager_api.c
===================================================================
--- gnunet/src/lockmanager/lockmanager_api.c 2012-06-20 14:18:02 UTC (rev
22157)
+++ gnunet/src/lockmanager/lockmanager_api.c 2012-06-20 14:24:45 UTC (rev
22158)
@@ -24,11 +24,6 @@
* @author Sree Harsha Totakura
*/
-/**
- * To be fixed:
- * Should the handle be freed when the connection to service is lost?
- * Should cancel_request have a call back (else simultaneous calls break)
- */
#include "platform.h"
#include "gnunet_common.h"
@@ -244,11 +239,11 @@
}
if (GNUNET_NO == handle->in_replies)
{
+ handle->in_replies = GNUNET_YES;
GNUNET_CLIENT_receive (handle->conn,
&handle_replies,
handle,
GNUNET_TIME_UNIT_FOREVER_REL);
- handle->in_replies = GNUNET_YES;
}
return msg_size;
}
@@ -325,7 +320,7 @@
if ( (match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)) )
{
- match->matched_entry = lr;
+ match->matched_entry = lr;
return GNUNET_NO;
}
return GNUNET_YES;
@@ -478,11 +473,11 @@
handle);
return;
}
+ handle->in_replies = GNUNET_YES;
GNUNET_CLIENT_receive (handle->conn,
&handle_replies,
handle,
GNUNET_TIME_UNIT_FOREVER_REL);
- handle->in_replies = GNUNET_YES;
if (GNUNET_MESSAGE_TYPE_LOCKMANAGER_SUCCESS != ntohs(msg->type))
{
GNUNET_break (0);
@@ -588,11 +583,11 @@
}
h->hashmap = GNUNET_CONTAINER_multihashmap_create (15);
GNUNET_assert (NULL != h->hashmap);
+ h->in_replies = GNUNET_YES;
GNUNET_CLIENT_receive (h->conn,
&handle_replies,
h,
- GNUNET_TIME_UNIT_FOREVER_REL);
- h->in_replies = GNUNET_YES;
+ GNUNET_TIME_UNIT_FOREVER_REL);
LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__);
return h;
}
Modified: gnunet/src/lockmanager/test_lockmanager_api.c
===================================================================
--- gnunet/src/lockmanager/test_lockmanager_api.c 2012-06-20 14:18:02 UTC
(rev 22157)
+++ gnunet/src/lockmanager/test_lockmanager_api.c 2012-06-20 14:24:45 UTC
(rev 22158)
@@ -27,11 +27,11 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_lockmanager_service.h"
+#include "gnunet_testing_lib-new.h"
-#define VERBOSE GNUNET_YES
-
-#define VERBOSE_ARM 1
-
+/**
+ * Generic logging shortcut
+ */
#define LOG(kind,...) \
GNUNET_log (kind, __VA_ARGS__)
@@ -60,14 +60,9 @@
static enum Test result;
/**
- * The process id of the GNUNET ARM process
- */
-static struct GNUNET_OS_Process *arm_pid = NULL;
-
-/**
* Configuration Handle
*/
-static struct GNUNET_CONFIGURATION_Handle *config;
+static const struct GNUNET_CONFIGURATION_Handle *config;
/**
* The handle to the lockmanager service
@@ -108,16 +103,7 @@
if (NULL != request2)
GNUNET_LOCKMANAGER_cancel_request (request2);
GNUNET_LOCKMANAGER_disconnect (handle);
- if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Kill gnunet-service-arm manually\n");
- }
- GNUNET_OS_process_wait (arm_pid);
- GNUNET_OS_process_destroy (arm_pid);
-
- if (NULL != config)
- GNUNET_CONFIGURATION_destroy (config);
+ GNUNET_SCHEDULER_shutdown ();
}
@@ -186,14 +172,15 @@
/**
- * Testing function
- *
- * @param cls NULL
- * @param tc the task context
+ * Main point of test execution
*/
static void
-test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const struct GNUNET_TESTING_Peer *peer)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting test...\n");
+ config = cfg;
handle = GNUNET_LOCKMANAGER_connect (config);
GNUNET_assert (NULL != handle);
result = LOCK1_ACQUIRE;
@@ -202,78 +189,22 @@
99,
&status_cb,
NULL);
- abort_task_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (10),
+ abort_task_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (30),
&do_abort,
NULL);
}
/**
- * Main point of test execution
- */
-static void
-run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting test...\n");
- config = GNUNET_CONFIGURATION_dup (cfg);
- arm_pid =
- GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm",
-#if VERBOSE_ARM
- "-L", "DEBUG",
-#endif
- "-c", "test_lockmanager_api.conf", NULL);
-
- GNUNET_assert (NULL != arm_pid);
- GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (3),
- &test,
- NULL);
-}
-
-
-/**
* Main function
*/
int main (int argc, char **argv)
{
- int ret;
- char *const argv2[] = { "test_lockmanager_api",
- "-c", "test_lockmanager_api.conf",
-#if VERBOSE
- "-L", "DEBUG",
-#endif
- NULL
- };
-
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_log_setup ("test_lockmanager_api",
-#if VERBOSE
- "DEBUG",
-#else
- "WARNING",
-#endif
- NULL);
-
- ret =
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_lockmanager_api", "nohelp", options, &run, NULL);
-
- if (GNUNET_OK != ret)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "run failed with error code %d\n",
- ret);
+ if (0 != GNUNET_TESTING_service_run_restartable ("test_lockmanager_api",
+ "arm",
+ "test_lockmanager_api.conf",
+ &run, NULL))
return 1;
- }
- if (TEST_FAIL == result)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "test failed\n");
- return 1;
- }
- LOG (GNUNET_ERROR_TYPE_INFO, "test OK\n");
- return 0;
+ return (TEST_FAIL == result) ? 1 : 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22158 - gnunet/src/lockmanager,
gnunet <=