aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-12-28 15:00:08 (GMT)
committerJouni Malinen <j@w1.fi>2013-12-29 08:00:32 (GMT)
commitc89d9dba9c407e4f17b096af63f692a994257b36 (patch)
tree9d3929db4456c514fff33b9e176529f287e4935a
parentc86bf160a7f47998b39aace6bdaf2a0d35909f11 (diff)
downloadhostap-c89d9dba9c407e4f17b096af63f692a994257b36.zip
hostap-c89d9dba9c407e4f17b096af63f692a994257b36.tar.gz
hostap-c89d9dba9c407e4f17b096af63f692a994257b36.tar.bz2
Remove unnecessary extra tracking of eloop registration
It is fine to try to cancel a registration that does not exist, so there is no need to have the duplicated checks for eloop timeout and socket registration. Signed-hostap: Jouni Malinen <j@w1.fi>
-rw-r--r--src/wps/httpread.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/src/wps/httpread.c b/src/wps/httpread.c
index e2f7c7c..b51d975 100644
--- a/src/wps/httpread.c
+++ b/src/wps/httpread.c
@@ -67,8 +67,6 @@ struct httpread {
int timeout_seconds; /* 0 or total duration timeout period */
/* dynamically used information follows */
- int sd_registered; /* nonzero if we need to unregister socket */
- int to_registered; /* nonzero if we need to unregister timeout */
int got_hdr; /* nonzero when header is finalized */
char hdr[HTTPREAD_HEADER_MAX_SIZE+1]; /* headers stored here */
@@ -143,12 +141,8 @@ void httpread_destroy(struct httpread *h)
if (!h)
return;
- if (h->to_registered)
- eloop_cancel_timeout(httpread_timeout_handler, NULL, h);
- h->to_registered = 0;
- if (h->sd_registered)
- eloop_unregister_sock(h->sd, EVENT_TYPE_READ);
- h->sd_registered = 0;
+ eloop_cancel_timeout(httpread_timeout_handler, NULL, h);
+ eloop_unregister_sock(h->sd, EVENT_TYPE_READ);
os_free(h->body);
os_free(h->uri);
os_memset(h, 0, sizeof(*h)); /* aid debugging */
@@ -163,7 +157,6 @@ static void httpread_timeout_handler(void *eloop_data, void *user_ctx)
{
struct httpread *h = user_ctx;
wpa_printf(MSG_DEBUG, "httpread timeout (%p)", h);
- h->to_registered = 0; /* is self-cancelling */
(*h->cb)(h, h->cookie, HTTPREAD_EVENT_TIMEOUT);
}
@@ -689,15 +682,11 @@ got_file:
* and just in case somehow we don't get destroyed right away,
* unregister now.
*/
- if (h->sd_registered)
- eloop_unregister_sock(h->sd, EVENT_TYPE_READ);
- h->sd_registered = 0;
+ eloop_unregister_sock(h->sd, EVENT_TYPE_READ);
/* The application can destroy us whenever they feel like...
* cancel timeout.
*/
- if (h->to_registered)
- eloop_cancel_timeout(httpread_timeout_handler, NULL, h);
- h->to_registered = 0;
+ eloop_cancel_timeout(httpread_timeout_handler, NULL, h);
(*h->cb)(h, h->cookie, HTTPREAD_EVENT_FILE_READY);
}
@@ -735,21 +724,17 @@ struct httpread * httpread_create(
h->max_bytes = max_bytes;
h->timeout_seconds = timeout_seconds;
- if (timeout_seconds > 0) {
- if (eloop_register_timeout(timeout_seconds, 0,
- httpread_timeout_handler,
- NULL, h)) {
- /* No way to recover (from malloc failure) */
- goto fail;
- }
- h->to_registered = 1;
+ if (timeout_seconds > 0 &&
+ eloop_register_timeout(timeout_seconds, 0,
+ httpread_timeout_handler, NULL, h)) {
+ /* No way to recover (from malloc failure) */
+ goto fail;
}
if (eloop_register_sock(sd, EVENT_TYPE_READ, httpread_read_handler,
NULL, h)) {
/* No way to recover (from malloc failure) */
goto fail;
}
- h->sd_registered = 1;
return h;
fail: