diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-05 09:56:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-05 09:56:25 +0000 |
commit | d75fb1880a887a8f5339c5e8cf5e9d2b8755fdad (patch) | |
tree | f8dff53b4b88b0d87ca31a772607ee51fb0653ec /src/include/gnunet_arm_service.h | |
parent | b9b0940e261a4b1713d909f0a2fd54134ed5b148 (diff) | |
download | gnunet-d75fb1880a887a8f5339c5e8cf5e9d2b8755fdad.tar.gz gnunet-d75fb1880a887a8f5339c5e8cf5e9d2b8755fdad.zip |
improving ARM API
Diffstat (limited to 'src/include/gnunet_arm_service.h')
-rw-r--r-- | src/include/gnunet_arm_service.h | 92 |
1 files changed, 79 insertions, 13 deletions
diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h index bbb8cb0f6..8e68cd5ee 100644 --- a/src/include/gnunet_arm_service.h +++ b/src/include/gnunet_arm_service.h | |||
@@ -58,45 +58,111 @@ typedef void (*GNUNET_ARM_Callback) (void *cls, int success); | |||
58 | 58 | ||
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Start a service. | 61 | * Handle for interacting with ARM. |
62 | */ | ||
63 | struct GNUNET_ARM_Handle; | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Setup a context for communicating with ARM. Note that this | ||
68 | * can be done even if the ARM service is not yet running. | ||
62 | * | 69 | * |
63 | * @param service_name name of the service | ||
64 | * @param cfg configuration to use (needed to contact ARM; | 70 | * @param cfg configuration to use (needed to contact ARM; |
65 | * the ARM service may internally use a different | 71 | * the ARM service may internally use a different |
66 | * configuration to determine how to start the service). | 72 | * configuration to determine how to start the service). |
67 | * @param sched scheduler to use | 73 | * @param sched scheduler to use |
74 | * @param service service that *this* process is implementing/providing, can be NULL | ||
75 | * @return context to use for further ARM operations, NULL on error | ||
76 | */ | ||
77 | struct GNUNET_ARM_Handle * | ||
78 | GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
79 | struct GNUNET_SCHEDULER_Handle *sched, | ||
80 | const char *service); | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Disconnect from the ARM service. | ||
85 | * | ||
86 | * @param h the handle that was being used | ||
87 | */ | ||
88 | void | ||
89 | GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h); | ||
90 | |||
91 | |||
92 | /** | ||
93 | * Start a service. Note that this function merely asks ARM to start | ||
94 | * the service and that ARM merely confirms that it forked the | ||
95 | * respective process. The specified callback may thus return before | ||
96 | * the service has started to listen on the server socket and it may | ||
97 | * also be that the service has crashed in the meantime. Clients | ||
98 | * should repeatedly try to connect to the service at the respective | ||
99 | * port (with some delays in between) before assuming that the service | ||
100 | * actually failed to start. Note that if an error is returned to the | ||
101 | * callback, clients obviously should not bother with trying to | ||
102 | * contact the service. | ||
103 | * | ||
104 | * @param h handle to ARM | ||
105 | * @param service_name name of the service | ||
68 | * @param timeout how long to wait before failing for good | 106 | * @param timeout how long to wait before failing for good |
69 | * @param cb callback to invoke when service is ready | 107 | * @param cb callback to invoke when service is ready |
70 | * @param cb_cls closure for callback | 108 | * @param cb_cls closure for callback |
71 | */ | 109 | */ |
72 | void | 110 | void |
73 | GNUNET_ARM_start_service (const char *service_name, | 111 | GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, |
74 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 112 | const char *service_name, |
75 | struct GNUNET_SCHEDULER_Handle *sched, | ||
76 | struct GNUNET_TIME_Relative timeout, | 113 | struct GNUNET_TIME_Relative timeout, |
77 | GNUNET_ARM_Callback cb, void *cb_cls); | 114 | GNUNET_ARM_Callback cb, void *cb_cls); |
78 | 115 | ||
79 | 116 | ||
80 | /** | 117 | /** |
81 | * Stop a service. | 118 | * Stop a service. Note that the callback is invoked as soon |
119 | * as ARM confirms that it will ask the service to terminate. | ||
120 | * The actual termination may still take some time. | ||
82 | * | 121 | * |
122 | * @param h handle to ARM | ||
83 | * @param service_name name of the service | 123 | * @param service_name name of the service |
84 | * @param cfg configuration to use (needed to contact ARM; | ||
85 | * the ARM service may internally use a different | ||
86 | * configuration to determine how to start the service). | ||
87 | * @param sched scheduler to use | ||
88 | * @param timeout how long to wait before failing for good | 124 | * @param timeout how long to wait before failing for good |
89 | * @param cb callback to invoke when service is ready | 125 | * @param cb callback to invoke when service is ready |
90 | * @param cb_cls closure for callback | 126 | * @param cb_cls closure for callback |
91 | */ | 127 | */ |
92 | void | 128 | void |
93 | GNUNET_ARM_stop_service (const char *service_name, | 129 | GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, |
94 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 130 | const char *service_name, |
95 | struct GNUNET_SCHEDULER_Handle *sched, | ||
96 | struct GNUNET_TIME_Relative timeout, | 131 | struct GNUNET_TIME_Relative timeout, |
97 | GNUNET_ARM_Callback cb, void *cb_cls); | 132 | GNUNET_ARM_Callback cb, void *cb_cls); |
98 | 133 | ||
99 | 134 | ||
135 | /** | ||
136 | * Start multiple services in the specified order. Convenience | ||
137 | * function. Works asynchronously, failures are not reported. | ||
138 | * | ||
139 | * @param cfg configuration to use (needed to contact ARM; | ||
140 | * the ARM service may internally use a different | ||
141 | * configuration to determine how to start the service). | ||
142 | * @param sched scheduler to use | ||
143 | * @param ... NULL-terminated list of service names (const char*) | ||
144 | */ | ||
145 | void | ||
146 | GNUNET_ARM_start_services (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
147 | struct GNUNET_SCHEDULER_Handle *sched, | ||
148 | ...); | ||
149 | |||
150 | |||
151 | /** | ||
152 | * Stop multiple services in the specified order. Convenience | ||
153 | * function. Works asynchronously, failures are not reported. | ||
154 | * | ||
155 | * @param cfg configuration to use (needed to contact ARM; | ||
156 | * the ARM service may internally use a different | ||
157 | * configuration to determine how to start the service). | ||
158 | * @param sched scheduler to use | ||
159 | * @param ... NULL-terminated list of service names (const char*) | ||
160 | */ | ||
161 | void | ||
162 | GNUNET_ARM_stop_services (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
163 | struct GNUNET_SCHEDULER_Handle *sched, | ||
164 | ...); | ||
165 | |||
100 | 166 | ||
101 | #if 0 /* keep Emacsens' auto-indent happy */ | 167 | #if 0 /* keep Emacsens' auto-indent happy */ |
102 | { | 168 | { |