From 2a630031fd3c868733e3038c3e19ad4b53a8d8ce Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 22 Jun 2011 15:39:00 +0200 Subject: [PATCH] core: display error (only once) when bad file descriptor is detected in hook_fd --- doc/de/autogen/plugin_api/hdata.txt | 3 ++- doc/en/autogen/plugin_api/hdata.txt | 3 ++- doc/fr/autogen/plugin_api/hdata.txt | 3 ++- doc/it/autogen/plugin_api/hdata.txt | 3 ++- po/cs.po | 6 +++++- po/de.po | 6 +++++- po/es.po | 6 +++++- po/fr.po | 8 ++++++-- po/hu.po | 6 +++++- po/it.po | 6 +++++- po/pl.po | 6 +++++- po/pt_BR.po | 6 +++++- po/ru.po | 6 +++++- po/weechat.pot | 6 +++++- src/core/wee-hook.c | 21 +++++++++++++++++++-- src/core/wee-hook.h | 2 ++ 16 files changed, 80 insertions(+), 17 deletions(-) diff --git a/doc/de/autogen/plugin_api/hdata.txt b/doc/de/autogen/plugin_api/hdata.txt index 26a3670c7..d9790f084 100644 --- a/doc/de/autogen/plugin_api/hdata.txt +++ b/doc/de/autogen/plugin_api/hdata.txt @@ -444,7 +444,8 @@ | weechat | hook_fd | Hook vom Typ "fd" | 'callback' (pointer) + 'fd' (integer) + - 'flags' (integer) | + 'flags' (integer) + + 'error' (integer) | 'last_weechat_hook_fd' + 'weechat_hooks_fd' diff --git a/doc/en/autogen/plugin_api/hdata.txt b/doc/en/autogen/plugin_api/hdata.txt index 30810edcf..09bfaa827 100644 --- a/doc/en/autogen/plugin_api/hdata.txt +++ b/doc/en/autogen/plugin_api/hdata.txt @@ -444,7 +444,8 @@ | weechat | hook_fd | hook of type "fd" | 'callback' (pointer) + 'fd' (integer) + - 'flags' (integer) | + 'flags' (integer) + + 'error' (integer) | 'last_weechat_hook_fd' + 'weechat_hooks_fd' diff --git a/doc/fr/autogen/plugin_api/hdata.txt b/doc/fr/autogen/plugin_api/hdata.txt index c9fb6ac03..67b770070 100644 --- a/doc/fr/autogen/plugin_api/hdata.txt +++ b/doc/fr/autogen/plugin_api/hdata.txt @@ -444,7 +444,8 @@ | weechat | hook_fd | hook de type "fd" | 'callback' (pointer) + 'fd' (integer) + - 'flags' (integer) | + 'flags' (integer) + + 'error' (integer) | 'last_weechat_hook_fd' + 'weechat_hooks_fd' diff --git a/doc/it/autogen/plugin_api/hdata.txt b/doc/it/autogen/plugin_api/hdata.txt index 0114c6110..e707c8d8a 100644 --- a/doc/it/autogen/plugin_api/hdata.txt +++ b/doc/it/autogen/plugin_api/hdata.txt @@ -444,7 +444,8 @@ | weechat | hook_fd | hook of type "fd" | 'callback' (pointer) + 'fd' (integer) + - 'flags' (integer) | + 'flags' (integer) + + 'error' (integer) | 'last_weechat_hook_fd' + 'weechat_hooks_fd' diff --git a/po/cs.po b/po/cs.po index 8b02b93b7..f4a5715b8 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: 2011-05-15 10:51+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -2694,6 +2694,10 @@ msgid "System clock skew detected (%+ld seconds), reinitializing all timers" msgstr "" "Detekován posun systémových hodin (%+ld sekund), znovu inicializuji časovače" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "Konec příkazu '%s', vypršel časový limit (%.lfs)" diff --git a/po/de.po b/po/de.po index d19ef0d4e..d64572906 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-22 10:56+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: 2011-06-15 18:51+0100\n" "Last-Translator: Nils G.\n" "Language-Team: weechat-dev \n" @@ -2832,6 +2832,10 @@ msgid "System clock skew detected (%+ld seconds), reinitializing all timers" msgstr "" "Die Systemzeit ist nicht korrekt (%+ld Sekunden), reinitialisiere alle Uhren" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "Befehl '%s' beendet, Zeit ist verstrichen (%.1fs)" diff --git a/po/es.po b/po/es.po index eefe27f28..a21c8425a 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: 2011-05-15 10:51+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -2746,6 +2746,10 @@ msgstr "" "Desviación detectada en el reloj del sistema (%+ld segundos), reiniciando " "todos los temporizadores" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "Fin del comando '%s', tiempo de espera alcanzado (%.1fs)" diff --git a/po/fr.po b/po/fr.po index 33738e72b..cc14620a1 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" -"PO-Revision-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" +"PO-Revision-Date: 2011-06-22 15:28+0200\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -2777,6 +2777,10 @@ msgstr "" "Décalage de l'horloge système détecté (%+ld secondes), réinitialisation de " "tous les minuteurs" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "%sErreur: mauvais descripteur de fichier (%d) utilisé dans hook_fd" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "Fin de la commande '%s', temps maximum atteint (%.1fs)" diff --git a/po/hu.po b/po/hu.po index d91c8c5ec..86b8ffdd8 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: 2011-05-15 10:51+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -2395,6 +2395,10 @@ msgstr "%s az ignore már létezik\n" msgid "System clock skew detected (%+ld seconds), reinitializing all timers" msgstr "" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "" diff --git a/po/it.po b/po/it.po index a40bc8889..d1477491a 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: 2011-05-15 10:52+0200\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -2746,6 +2746,10 @@ msgstr "" "Rilevato ritardo nell'orologio di sistema (%+ld secondi), reset di tutti i " "timer" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "Fine comando '%s', timeout raggiunto (%.1fs)" diff --git a/po/pl.po b/po/pl.po index 46922b83b..47fc3c1ef 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: 2011-05-15 10:52+0200\n" "Last-Translator: Krzysztof Koroscik \n" "Language-Team: weechat-dev \n" @@ -2730,6 +2730,10 @@ msgstr "" "Wykryto odchylenie zegara systemowego (%+ld sekund), reinicjalisuje " "wszystkie timery" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "Kończenie komendy '%s', przekroczono dopuszczalny czas (%.1fs)" diff --git a/po/pt_BR.po b/po/pt_BR.po index 3a0d6a755..33e74da33 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: 2011-05-15 10:52+0200\n" "Last-Translator: Ivan Sichmann Freitas \n" "Language-Team: weechat-dev \n" @@ -2658,6 +2658,10 @@ msgstr "" msgid "System clock skew detected (%+ld seconds), reinitializing all timers" msgstr "" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "" diff --git a/po/ru.po b/po/ru.po index b9da6ea4c..4158b15ae 100644 --- a/po/ru.po +++ b/po/ru.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.6-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: 2011-05-15 10:52+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -2410,6 +2410,10 @@ msgstr "%s игнорирование уже существует\n" msgid "System clock skew detected (%+ld seconds), reinitializing all timers" msgstr "" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index f2dba9b04..15efd0c22 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-06-13 21:33+0200\n" +"POT-Creation-Date: 2011-06-22 15:36+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2062,6 +2062,10 @@ msgstr "" msgid "System clock skew detected (%+ld seconds), reinitializing all timers" msgstr "" +#, c-format +msgid "%sError: bad file descriptor (%d) used in hook_fd" +msgstr "" + #, c-format msgid "End of command '%s', timeout reached (%.1fs)" msgstr "" diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index ffea7a7ac..15b2f2a6c 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -1194,6 +1194,7 @@ hook_fd (struct t_weechat_plugin *plugin, int fd, int flag_read, new_hook_fd->callback = callback; new_hook_fd->fd = fd; new_hook_fd->flags = 0; + new_hook_fd->error = 0; if (flag_read) new_hook_fd->flags |= HOOK_FD_FLAG_READ; if (flag_write) @@ -1224,8 +1225,20 @@ hook_fd_set (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds) if (!ptr_hook->deleted) { /* skip invalid file descriptors */ - if ((fcntl (HOOK_FD(ptr_hook,fd), F_GETFD) != -1) - || (errno != EBADF)) + if ((fcntl (HOOK_FD(ptr_hook,fd), F_GETFD) == -1) + && (errno == EBADF)) + { + if (HOOK_FD(ptr_hook, error) == 0) + { + HOOK_FD(ptr_hook, error) = errno; + gui_chat_printf (NULL, + _("%sError: bad file descriptor (%d) " + "used in hook_fd"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + HOOK_FD(ptr_hook, fd)); + } + } + else { if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_READ) { @@ -3152,6 +3165,7 @@ hook_hdata_hook_fd_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_hook_fd, callback, POINTER); HDATA_VAR(struct t_hook_fd, fd, INTEGER); HDATA_VAR(struct t_hook_fd, flags, INTEGER); + HDATA_VAR(struct t_hook_fd, error, INTEGER); hdata_new_list(hdata, "weechat_hooks_fd", &weechat_hooks[HOOK_TYPE_FD]); hdata_new_list(hdata, "last_weechat_hook_fd", &last_weechat_hook[HOOK_TYPE_FD]); } @@ -3654,6 +3668,8 @@ hook_add_to_infolist_type (struct t_infolist *infolist, int type, return 0; if (!infolist_new_var_integer (ptr_item, "flags", HOOK_FD(ptr_hook, flags))) return 0; + if (!infolist_new_var_integer (ptr_item, "error", HOOK_FD(ptr_hook, error))) + return 0; } break; case HOOK_TYPE_PROCESS: @@ -4051,6 +4067,7 @@ hook_print_log () log_printf (" callback. . . . . . . : 0x%lx", HOOK_FD(ptr_hook, callback)); log_printf (" fd. . . . . . . . . . : %d", HOOK_FD(ptr_hook, fd)); log_printf (" flags . . . . . . . . : %d", HOOK_FD(ptr_hook, flags)); + log_printf (" error . . . . . . . . : %d", HOOK_FD(ptr_hook, error)); } break; case HOOK_TYPE_PROCESS: diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index 14080b71e..054976259 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -174,6 +174,8 @@ struct t_hook_fd t_hook_callback_fd *callback; /* fd callback */ int fd; /* socket or file descriptor */ int flags; /* fd flags (read,write,..) */ + int error; /* contains errno if error occured */ + /* with fd */ }; /* hook process */