diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-15 10:04:40 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-15 10:04:40 +0000 |
commit | 33769b2c1d815d73727a01bc9b785a951b4d29a1 (patch) | |
tree | 80835e247735b773cc603c3cfc5d41aadd112574 /src/transport/plugin_transport_http_client.c | |
parent | c2a2296221c174ae68fb82f3373a5594391474cb (diff) | |
download | gnunet-33769b2c1d815d73727a01bc9b785a951b4d29a1.tar.gz gnunet-33769b2c1d815d73727a01bc9b785a951b4d29a1.zip |
pre-launch commit
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 89 |
1 files changed, 50 insertions, 39 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 41300285a..312d5a78d 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -58,39 +58,6 @@ client_log (CURL * curl, curl_infotype type, char *data, size_t size, void *cls) | |||
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | int | 60 | int |
61 | client_disconnect (struct Session *s) | ||
62 | { | ||
63 | int res = GNUNET_OK; | ||
64 | CURLMcode mret; | ||
65 | |||
66 | #if DEBUG_HTTP | ||
67 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, | ||
68 | "Deleting outbound session peer `%s'\n", | ||
69 | GNUNET_i2s (&s->target)); | ||
70 | #endif | ||
71 | |||
72 | mret = curl_multi_remove_handle (s->plugin->client_mh, s->client_put); | ||
73 | if (mret != CURLM_OK) | ||
74 | { | ||
75 | curl_easy_cleanup (s->client_put); | ||
76 | res = GNUNET_SYSERR; | ||
77 | GNUNET_break (0); | ||
78 | } | ||
79 | curl_easy_cleanup (s->client_put); | ||
80 | |||
81 | mret = curl_multi_remove_handle (s->plugin->client_mh, s->client_get); | ||
82 | if (mret != CURLM_OK) | ||
83 | { | ||
84 | curl_easy_cleanup (s->client_get); | ||
85 | res = GNUNET_SYSERR; | ||
86 | GNUNET_break (0); | ||
87 | } | ||
88 | curl_easy_cleanup (s->client_get); | ||
89 | |||
90 | return res; | ||
91 | } | ||
92 | |||
93 | int | ||
94 | client_send (struct Session *s, const char *msgbuf, size_t msgbuf_size) | 61 | client_send (struct Session *s, const char *msgbuf, size_t msgbuf_size) |
95 | { | 62 | { |
96 | return GNUNET_OK; | 63 | return GNUNET_OK; |
@@ -102,7 +69,7 @@ client_send (struct Session *s, const char *msgbuf, size_t msgbuf_size) | |||
102 | * @param tc gnunet scheduler task context | 69 | * @param tc gnunet scheduler task context |
103 | */ | 70 | */ |
104 | static void | 71 | static void |
105 | client_perform (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 72 | client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
106 | 73 | ||
107 | /** | 74 | /** |
108 | * Function setting up file descriptors and scheduling task to run | 75 | * Function setting up file descriptors and scheduling task to run |
@@ -111,7 +78,7 @@ client_perform (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
111 | * @return GNUNET_SYSERR for hard failure, GNUNET_OK for ok | 78 | * @return GNUNET_SYSERR for hard failure, GNUNET_OK for ok |
112 | */ | 79 | */ |
113 | static int | 80 | static int |
114 | client_schedule_next_perform (struct Plugin *plugin) | 81 | client_schedule (struct Plugin *plugin) |
115 | { | 82 | { |
116 | fd_set rs; | 83 | fd_set rs; |
117 | fd_set ws; | 84 | fd_set ws; |
@@ -165,7 +132,7 @@ client_schedule_next_perform (struct Plugin *plugin) | |||
165 | timeout, | 132 | timeout, |
166 | grs, | 133 | grs, |
167 | gws, | 134 | gws, |
168 | &client_perform, | 135 | &client_run, |
169 | plugin); | 136 | plugin); |
170 | GNUNET_NETWORK_fdset_destroy (gws); | 137 | GNUNET_NETWORK_fdset_destroy (gws); |
171 | GNUNET_NETWORK_fdset_destroy (grs); | 138 | GNUNET_NETWORK_fdset_destroy (grs); |
@@ -179,7 +146,7 @@ client_schedule_next_perform (struct Plugin *plugin) | |||
179 | * @param tc gnunet scheduler task context | 146 | * @param tc gnunet scheduler task context |
180 | */ | 147 | */ |
181 | static void | 148 | static void |
182 | client_perform (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 149 | client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
183 | { | 150 | { |
184 | struct Plugin *plugin = cls; | 151 | struct Plugin *plugin = cls; |
185 | static unsigned int handles_last_run; | 152 | static unsigned int handles_last_run; |
@@ -203,10 +170,54 @@ client_perform (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
203 | handles_last_run = running; | 170 | handles_last_run = running; |
204 | } | 171 | } |
205 | while (mret == CURLM_CALL_MULTI_PERFORM); | 172 | while (mret == CURLM_CALL_MULTI_PERFORM); |
206 | client_schedule_next_perform (plugin); | 173 | client_schedule (plugin); |
207 | } | 174 | } |
208 | 175 | ||
209 | int | 176 | int |
177 | client_disconnect (struct Session *s) | ||
178 | { | ||
179 | int res = GNUNET_OK; | ||
180 | CURLMcode mret; | ||
181 | struct Plugin *plugin = s->plugin; | ||
182 | |||
183 | #if DEBUG_HTTP | ||
184 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
185 | "Deleting outbound session peer `%s'\n", | ||
186 | GNUNET_i2s (&s->target)); | ||
187 | #endif | ||
188 | |||
189 | mret = curl_multi_remove_handle (plugin->client_mh, s->client_put); | ||
190 | if (mret != CURLM_OK) | ||
191 | { | ||
192 | curl_easy_cleanup (s->client_put); | ||
193 | res = GNUNET_SYSERR; | ||
194 | GNUNET_break (0); | ||
195 | } | ||
196 | curl_easy_cleanup (s->client_put); | ||
197 | |||
198 | mret = curl_multi_remove_handle (plugin->client_mh, s->client_get); | ||
199 | if (mret != CURLM_OK) | ||
200 | { | ||
201 | curl_easy_cleanup (s->client_get); | ||
202 | res = GNUNET_SYSERR; | ||
203 | GNUNET_break (0); | ||
204 | } | ||
205 | curl_easy_cleanup (s->client_get); | ||
206 | |||
207 | /* Re-schedule since handles have changed */ | ||
208 | if (plugin->client_perform_task!= GNUNET_SCHEDULER_NO_TASK) | ||
209 | { | ||
210 | GNUNET_SCHEDULER_cancel (plugin->client_perform_task); | ||
211 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; | ||
212 | } | ||
213 | |||
214 | plugin->client_perform_task = GNUNET_SCHEDULER_add_now(client_run, plugin); | ||
215 | |||
216 | return res; | ||
217 | } | ||
218 | |||
219 | |||
220 | int | ||
210 | client_connect (struct Session *s) | 221 | client_connect (struct Session *s) |
211 | { | 222 | { |
212 | int res = GNUNET_OK; | 223 | int res = GNUNET_OK; |
@@ -311,7 +322,7 @@ client_connect (struct Session *s) | |||
311 | } | 322 | } |
312 | 323 | ||
313 | /* Perform connect */ | 324 | /* Perform connect */ |
314 | s->plugin->client_perform_task = GNUNET_SCHEDULER_add_now (client_perform, s->plugin); | 325 | s->plugin->client_perform_task = GNUNET_SCHEDULER_add_now (client_run, s->plugin); |
315 | 326 | ||
316 | return res; | 327 | return res; |
317 | } | 328 | } |