diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-28 18:58:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-28 18:58:49 +0000 |
commit | 5cd8da882ab470bc9586ce68552a860fdbedfbbe (patch) | |
tree | 65865a4bc369efaf1863f043ad57dda3ab7465d4 /src/util/connection.c | |
parent | 70e4fde281b319ea93a454f8a8fa8a65d08c8969 (diff) | |
download | gnunet-5cd8da882ab470bc9586ce68552a860fdbedfbbe.tar.gz gnunet-5cd8da882ab470bc9586ce68552a860fdbedfbbe.zip |
-indentation, comments
Diffstat (limited to 'src/util/connection.c')
-rw-r--r-- | src/util/connection.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/util/connection.c b/src/util/connection.c index cd3ebad61..eb27fb3f5 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -245,7 +245,7 @@ struct GNUNET_CONNECTION_Handle | |||
245 | int8_t persist; | 245 | int8_t persist; |
246 | 246 | ||
247 | /** | 247 | /** |
248 | * Usually 0. Set to 1 if this handle is in used and should | 248 | * Usually 0. Set to 1 if this handle is in use, and should |
249 | * #GNUNET_CONNECTION_destroy() be called right now, the action needs | 249 | * #GNUNET_CONNECTION_destroy() be called right now, the action needs |
250 | * to be deferred by setting it to -1. | 250 | * to be deferred by setting it to -1. |
251 | */ | 251 | */ |
@@ -984,7 +984,10 @@ GNUNET_CONNECTION_check (struct GNUNET_CONNECTION_Handle *connection) | |||
984 | { | 984 | { |
985 | if ((NULL != connection->ap_head) || (NULL != connection->dns_active)) | 985 | if ((NULL != connection->ap_head) || (NULL != connection->dns_active)) |
986 | return GNUNET_YES; /* still trying to connect */ | 986 | return GNUNET_YES; /* still trying to connect */ |
987 | return (NULL == connection->sock) ? GNUNET_NO : GNUNET_YES; | 987 | if ( (0 != connection->destroy_later) || |
988 | (NULL == connection->sock) ) | ||
989 | return GNUNET_NO; | ||
990 | return GNUNET_YES; | ||
988 | } | 991 | } |
989 | 992 | ||
990 | 993 | ||
@@ -1078,7 +1081,8 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection) | |||
1078 | * @param tc scheduler context | 1081 | * @param tc scheduler context |
1079 | */ | 1082 | */ |
1080 | static void | 1083 | static void |
1081 | receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1084 | receive_ready (void *cls, |
1085 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1082 | { | 1086 | { |
1083 | struct GNUNET_CONNECTION_Handle *connection = cls; | 1087 | struct GNUNET_CONNECTION_Handle *connection = cls; |
1084 | char buffer[connection->max]; | 1088 | char buffer[connection->max]; |
@@ -1172,8 +1176,10 @@ GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection, | |||
1172 | { | 1176 | { |
1173 | connection->read_task = | 1177 | connection->read_task = |
1174 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining | 1178 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining |
1175 | (connection->receive_timeout), connection->sock, | 1179 | (connection->receive_timeout), |
1176 | &receive_ready, connection); | 1180 | connection->sock, |
1181 | &receive_ready, | ||
1182 | connection); | ||
1177 | return; | 1183 | return; |
1178 | } | 1184 | } |
1179 | if ((NULL == connection->dns_active) && (NULL == connection->ap_head)) | 1185 | if ((NULL == connection->dns_active) && (NULL == connection->ap_head)) |
@@ -1198,7 +1204,8 @@ GNUNET_CONNECTION_receive_cancel (struct GNUNET_CONNECTION_Handle *connection) | |||
1198 | { | 1204 | { |
1199 | if (NULL != connection->read_task) | 1205 | if (NULL != connection->read_task) |
1200 | { | 1206 | { |
1201 | GNUNET_assert (connection == GNUNET_SCHEDULER_cancel (connection->read_task)); | 1207 | GNUNET_assert (connection == |
1208 | GNUNET_SCHEDULER_cancel (connection->read_task)); | ||
1202 | connection->read_task = NULL; | 1209 | connection->read_task = NULL; |
1203 | } | 1210 | } |
1204 | connection->receiver = NULL; | 1211 | connection->receiver = NULL; |
@@ -1243,7 +1250,8 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection) | |||
1243 | if (connection->write_buffer_size - connection->write_buffer_off < size) | 1250 | if (connection->write_buffer_size - connection->write_buffer_off < size) |
1244 | { | 1251 | { |
1245 | /* need to compact */ | 1252 | /* need to compact */ |
1246 | memmove (connection->write_buffer, &connection->write_buffer[connection->write_buffer_pos], | 1253 | memmove (connection->write_buffer, |
1254 | &connection->write_buffer[connection->write_buffer_pos], | ||
1247 | used); | 1255 | used); |
1248 | connection->write_buffer_off -= connection->write_buffer_pos; | 1256 | connection->write_buffer_off -= connection->write_buffer_pos; |
1249 | connection->write_buffer_pos = 0; | 1257 | connection->write_buffer_pos = 0; |
@@ -1272,7 +1280,8 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection) | |||
1272 | * @param tc scheduler context | 1280 | * @param tc scheduler context |
1273 | */ | 1281 | */ |
1274 | static void | 1282 | static void |
1275 | transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1283 | transmit_timeout (void *cls, |
1284 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1276 | { | 1285 | { |
1277 | struct GNUNET_CONNECTION_Handle *connection = cls; | 1286 | struct GNUNET_CONNECTION_Handle *connection = cls; |
1278 | GNUNET_CONNECTION_TransmitReadyNotify notify; | 1287 | GNUNET_CONNECTION_TransmitReadyNotify notify; |
@@ -1281,7 +1290,10 @@ transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1281 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1290 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1282 | "Transmit to `%s:%u/%s' fails, time out reached (%p).\n", | 1291 | "Transmit to `%s:%u/%s' fails, time out reached (%p).\n", |
1283 | connection->hostname, | 1292 | connection->hostname, |
1284 | connection->port, GNUNET_a2s (connection->addr, connection->addrlen), connection); | 1293 | connection->port, |
1294 | GNUNET_a2s (connection->addr, | ||
1295 | connection->addrlen), | ||
1296 | connection); | ||
1285 | notify = connection->nth.notify_ready; | 1297 | notify = connection->nth.notify_ready; |
1286 | GNUNET_assert (NULL != notify); | 1298 | GNUNET_assert (NULL != notify); |
1287 | connection->nth.notify_ready = NULL; | 1299 | connection->nth.notify_ready = NULL; |
@@ -1299,14 +1311,18 @@ transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1299 | * @param tc scheduler context | 1311 | * @param tc scheduler context |
1300 | */ | 1312 | */ |
1301 | static void | 1313 | static void |
1302 | connect_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1314 | connect_error (void *cls, |
1315 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1303 | { | 1316 | { |
1304 | struct GNUNET_CONNECTION_Handle *connection = cls; | 1317 | struct GNUNET_CONNECTION_Handle *connection = cls; |
1305 | GNUNET_CONNECTION_TransmitReadyNotify notify; | 1318 | GNUNET_CONNECTION_TransmitReadyNotify notify; |
1306 | 1319 | ||
1307 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1320 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1308 | "Transmission request of size %u fails (%s/%u), connection failed (%p).\n", | 1321 | "Transmission request of size %u fails (%s/%u), connection failed (%p).\n", |
1309 | connection->nth.notify_size, connection->hostname, connection->port, connection); | 1322 | connection->nth.notify_size, |
1323 | connection->hostname, | ||
1324 | connection->port, | ||
1325 | connection); | ||
1310 | connection->write_task = NULL; | 1326 | connection->write_task = NULL; |
1311 | notify = connection->nth.notify_ready; | 1327 | notify = connection->nth.notify_ready; |
1312 | connection->nth.notify_ready = NULL; | 1328 | connection->nth.notify_ready = NULL; |
@@ -1519,9 +1535,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec | |||
1519 | * @param th notification to cancel | 1535 | * @param th notification to cancel |
1520 | */ | 1536 | */ |
1521 | void | 1537 | void |
1522 | GNUNET_CONNECTION_notify_transmit_ready_cancel (struct | 1538 | GNUNET_CONNECTION_notify_transmit_ready_cancel (struct GNUNET_CONNECTION_TransmitHandle *th) |
1523 | GNUNET_CONNECTION_TransmitHandle | ||
1524 | *th) | ||
1525 | { | 1539 | { |
1526 | GNUNET_assert (NULL != th->notify_ready); | 1540 | GNUNET_assert (NULL != th->notify_ready); |
1527 | th->notify_ready = NULL; | 1541 | th->notify_ready = NULL; |