eloop: Do not use printf() or fprintf() directly

This commit is contained in:
Jouni Malinen 2009-12-19 20:27:55 +02:00
parent eaa3f04b97
commit f45fb672cc

View file

@ -1,6 +1,6 @@
/* /*
* Event loop based on select() loop * Event loop based on select() loop
* Copyright (c) 2002-2005, Jouni Malinen <j@w1.fi> * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
@ -186,12 +186,13 @@ static void eloop_sock_table_destroy(struct eloop_sock_table *table)
if (table) { if (table) {
int i; int i;
for (i = 0; i < table->count && table->table; i++) { for (i = 0; i < table->count && table->table; i++) {
printf("ELOOP: remaining socket: sock=%d " wpa_printf(MSG_INFO, "ELOOP: remaining socket: "
"eloop_data=%p user_data=%p handler=%p\n", "sock=%d eloop_data=%p user_data=%p "
table->table[i].sock, "handler=%p\n",
table->table[i].eloop_data, table->table[i].sock,
table->table[i].user_data, table->table[i].eloop_data,
table->table[i].handler); table->table[i].user_data,
table->table[i].handler);
wpa_trace_dump("eloop sock", &table->table[i]); wpa_trace_dump("eloop sock", &table->table[i]);
} }
os_free(table->table); os_free(table->table);
@ -328,11 +329,11 @@ int eloop_is_timeout_registered(eloop_timeout_handler handler,
#ifndef CONFIG_NATIVE_WINDOWS #ifndef CONFIG_NATIVE_WINDOWS
static void eloop_handle_alarm(int sig) static void eloop_handle_alarm(int sig)
{ {
fprintf(stderr, "eloop: could not process SIGINT or SIGTERM in two " wpa_printf(MSG_ERROR, "eloop: could not process SIGINT or SIGTERM in "
"seconds. Looks like there\n" "two seconds. Looks like there\n"
"is a bug that ends up in a busy loop that " "is a bug that ends up in a busy loop that "
"prevents clean shutdown.\n" "prevents clean shutdown.\n"
"Killing program forcefully.\n"); "Killing program forcefully.\n");
exit(1); exit(1);
} }
#endif /* CONFIG_NATIVE_WINDOWS */ #endif /* CONFIG_NATIVE_WINDOWS */
@ -442,10 +443,8 @@ void eloop_run(void)
rfds = os_malloc(sizeof(*rfds)); rfds = os_malloc(sizeof(*rfds));
wfds = os_malloc(sizeof(*wfds)); wfds = os_malloc(sizeof(*wfds));
efds = os_malloc(sizeof(*efds)); efds = os_malloc(sizeof(*efds));
if (rfds == NULL || wfds == NULL || efds == NULL) { if (rfds == NULL || wfds == NULL || efds == NULL)
printf("eloop_run - malloc failed\n");
goto out; goto out;
}
while (!eloop.terminate && while (!eloop.terminate &&
(!dl_list_empty(&eloop.timeout) || eloop.readers.count > 0 || (!dl_list_empty(&eloop.timeout) || eloop.readers.count > 0 ||
@ -459,10 +458,6 @@ void eloop_run(void)
os_time_sub(&timeout->time, &now, &tv); os_time_sub(&timeout->time, &now, &tv);
else else
tv.sec = tv.usec = 0; tv.sec = tv.usec = 0;
#if 0
printf("next timeout in %lu.%06lu sec\n",
tv.sec, tv.usec);
#endif
_tv.tv_sec = tv.sec; _tv.tv_sec = tv.sec;
_tv.tv_usec = tv.usec; _tv.tv_usec = tv.usec;
} }