diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-10-10 15:47:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-10-10 15:47:00 +0000 |
commit | 93085e8a2991fde229400b588a5930e9fcca0d75 (patch) | |
tree | 0384246adbd96fa0138a46ad5fecb777aa40e789 /src/util | |
parent | 2bf962c76bb82c1f38acea42c7bdfb241e2582e7 (diff) | |
download | gnunet-93085e8a2991fde229400b588a5930e9fcca0d75.tar.gz gnunet-93085e8a2991fde229400b588a5930e9fcca0d75.zip |
migrating testbed to new service API
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/mq.c | 7 | ||||
-rw-r--r-- | src/util/service_new.c | 36 |
2 files changed, 36 insertions, 7 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index 3d6f27567..7c13265d8 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -295,9 +295,10 @@ GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, | |||
295 | } | 295 | } |
296 | done: | 296 | done: |
297 | if (GNUNET_NO == handled) | 297 | if (GNUNET_NO == handled) |
298 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 298 | LOG (GNUNET_ERROR_TYPE_INFO, |
299 | "No handler for message of type %d\n", | 299 | "No handler for message of type %d and size %d\n", |
300 | ntohs (mh->type)); | 300 | ntohs (mh->type), |
301 | ntohs (mh->size)); | ||
301 | } | 302 | } |
302 | 303 | ||
303 | 304 | ||
diff --git a/src/util/service_new.c b/src/util/service_new.c index 9929341f4..744adc387 100644 --- a/src/util/service_new.c +++ b/src/util/service_new.c | |||
@@ -136,7 +136,7 @@ struct GNUNET_SERVICE_Handle | |||
136 | /** | 136 | /** |
137 | * Message handlers to use for all clients. | 137 | * Message handlers to use for all clients. |
138 | */ | 138 | */ |
139 | const struct GNUNET_MQ_MessageHandler *handlers; | 139 | struct GNUNET_MQ_MessageHandler *handlers; |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * Closure for @e task. | 142 | * Closure for @e task. |
@@ -1616,12 +1616,24 @@ GNUNET_SERVICE_starT (const char *service_name, | |||
1616 | sh->connect_cb = connect_cb; | 1616 | sh->connect_cb = connect_cb; |
1617 | sh->disconnect_cb = disconnect_cb; | 1617 | sh->disconnect_cb = disconnect_cb; |
1618 | sh->cb_cls = cls; | 1618 | sh->cb_cls = cls; |
1619 | sh->handlers = handlers; | 1619 | if (NULL != handlers) |
1620 | { | ||
1621 | unsigned int i; | ||
1622 | |||
1623 | for (i=0;NULL != handlers[i].cb; i++) ; | ||
1624 | sh->handlers = GNUNET_new_array (i + 1, | ||
1625 | struct GNUNET_MQ_MessageHandler); | ||
1626 | GNUNET_memcpy (sh->handlers, | ||
1627 | handlers, | ||
1628 | i * sizeof (struct GNUNET_MQ_MessageHandler)); | ||
1629 | } | ||
1620 | if (GNUNET_OK != setup_service (sh)) | 1630 | if (GNUNET_OK != setup_service (sh)) |
1621 | { | 1631 | { |
1632 | GNUNET_free (sh->handlers); | ||
1622 | GNUNET_free (sh); | 1633 | GNUNET_free (sh); |
1623 | return NULL; | 1634 | return NULL; |
1624 | } | 1635 | } |
1636 | GNUNET_SERVICE_resume (sh); | ||
1625 | return sh; | 1637 | return sh; |
1626 | } | 1638 | } |
1627 | 1639 | ||
@@ -1634,7 +1646,13 @@ GNUNET_SERVICE_starT (const char *service_name, | |||
1634 | void | 1646 | void |
1635 | GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv) | 1647 | GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv) |
1636 | { | 1648 | { |
1649 | struct GNUNET_SERVICE_Client *client; | ||
1650 | |||
1651 | GNUNET_SERVICE_suspend (srv); | ||
1652 | while (NULL != (client = srv->clients_head)) | ||
1653 | GNUNET_SERVICE_client_drop (client); | ||
1637 | teardown_service (srv); | 1654 | teardown_service (srv); |
1655 | GNUNET_free (srv->handlers); | ||
1638 | GNUNET_free (srv); | 1656 | GNUNET_free (srv); |
1639 | } | 1657 | } |
1640 | 1658 | ||
@@ -1736,7 +1754,17 @@ GNUNET_SERVICE_ruN_ (int argc, | |||
1736 | sh.connect_cb = connect_cb; | 1754 | sh.connect_cb = connect_cb; |
1737 | sh.disconnect_cb = disconnect_cb; | 1755 | sh.disconnect_cb = disconnect_cb; |
1738 | sh.cb_cls = cls; | 1756 | sh.cb_cls = cls; |
1739 | sh.handlers = handlers; | 1757 | if (NULL != handlers) |
1758 | { | ||
1759 | unsigned int i; | ||
1760 | |||
1761 | for (i=0;NULL != handlers[i].cb; i++) ; | ||
1762 | sh.handlers = GNUNET_new_array (i + 1, | ||
1763 | struct GNUNET_MQ_MessageHandler); | ||
1764 | GNUNET_memcpy (sh.handlers, | ||
1765 | handlers, | ||
1766 | i * sizeof (struct GNUNET_MQ_MessageHandler)); | ||
1767 | } | ||
1740 | sh.service_name = service_name; | 1768 | sh.service_name = service_name; |
1741 | 1769 | ||
1742 | /* setup subsystems */ | 1770 | /* setup subsystems */ |
@@ -1867,7 +1895,7 @@ shutdown: | |||
1867 | } | 1895 | } |
1868 | #endif | 1896 | #endif |
1869 | teardown_service (&sh); | 1897 | teardown_service (&sh); |
1870 | 1898 | GNUNET_free (sh.handlers); | |
1871 | GNUNET_SPEEDUP_stop_ (); | 1899 | GNUNET_SPEEDUP_stop_ (); |
1872 | GNUNET_CONFIGURATION_destroy (cfg); | 1900 | GNUNET_CONFIGURATION_destroy (cfg); |
1873 | GNUNET_free_non_null (logfile); | 1901 | GNUNET_free_non_null (logfile); |