diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-13 06:57:06 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-13 06:57:06 +0200 |
commit | de4009fb4de679b2efe89e2736436060eb4a8e6d (patch) | |
tree | 295e3f632b2f9efdd858904b851602c5d77ef96e | |
parent | b2cc2709c6fcf8d3fdc123e6d926be2d02c1221f (diff) | |
download | ponymap-de4009fb4de679b2efe89e2736436060eb4a8e6d.tar.gz ponymap-de4009fb4de679b2efe89e2736436060eb4a8e6d.tar.xz ponymap-de4009fb4de679b2efe89e2736436060eb4a8e6d.zip |
Aborting units -> stopping units
-rw-r--r-- | plugin-api.h | 8 | ||||
-rw-r--r-- | plugins/http.c | 10 | ||||
-rw-r--r-- | plugins/irc.c | 4 | ||||
-rw-r--r-- | plugins/lua-loader.c | 14 | ||||
-rw-r--r-- | plugins/mpd.lua | 2 | ||||
-rw-r--r-- | plugins/socks.lua | 4 | ||||
-rw-r--r-- | plugins/ssh.c | 4 | ||||
-rw-r--r-- | ponymap.c | 46 |
8 files changed, 46 insertions, 46 deletions
diff --git a/plugin-api.h b/plugin-api.h index 740967f..3431e3c 100644 --- a/plugin-api.h +++ b/plugin-api.h @@ -39,7 +39,7 @@ struct service int flags; ///< Service flags void *user_data; ///< User data - // scan_init -> on_data* -> [on_eof/on_error] -> on_aborted -> scan_free + // scan_init -> on_data* -> [on_eof/on_error] -> on_stopped -> scan_free /// Initialize a scan, returning a handle to it void *(*scan_init) (struct service *self, struct unit *u); @@ -58,8 +58,8 @@ struct service /// Network or other error has occured void (*on_error) (void *handle); - /// The scan has been aborted - void (*on_aborted) (void *handle); + /// The scan has been stopped + void (*on_stopped) (void *handle); }; struct plugin_api @@ -83,7 +83,7 @@ struct plugin_api void (*unit_add_info) (struct unit *u, const char *result); /// Abort the scan, close the connection - void (*unit_abort) (struct unit *u); + void (*unit_stop) (struct unit *u); }; struct plugin_info diff --git a/plugins/http.c b/plugins/http.c index 2064e87..35e3d70 100644 --- a/plugins/http.c +++ b/plugins/http.c @@ -90,7 +90,7 @@ on_headers_complete (http_parser *parser) struct scan_data *scan = parser->data; // We've got this far, this must be an HTTP server g_data.api->unit_set_success (scan->u, true); - g_data.api->unit_abort (scan->u); + g_data.api->unit_stop (scan->u); return 1; } @@ -144,12 +144,12 @@ on_data (void *handle, const void *data, size_t len) if (parser->upgrade) { // We should never get here though because `on_headers_complete' - // is called first and ends up aborting the unit. + // is called first and ends up stopping the unit. g_data.api->unit_add_info (scan->u, "upgrades to a different protocol"); - g_data.api->unit_abort (scan->u); + g_data.api->unit_stop (scan->u); } else if (n_parsed != len && parser->http_errno != HPE_CB_headers_complete) - g_data.api->unit_abort (scan->u); + g_data.api->unit_stop (scan->u); } static void @@ -168,7 +168,7 @@ static struct service g_http_service = .on_data = on_data, .on_eof = on_eof, .on_error = NULL, - .on_aborted = NULL + .on_stopped = NULL }; static bool diff --git a/plugins/irc.c b/plugins/irc.c index 03cd0df..156d4b5 100644 --- a/plugins/irc.c +++ b/plugins/irc.c @@ -107,7 +107,7 @@ on_irc_message (const struct irc_message *msg, const char *raw, void *user_data) g_data.api->unit_add_info (scan->u, info); free (info); - g_data.api->unit_abort (scan->u); + g_data.api->unit_stop (scan->u); } } } @@ -130,7 +130,7 @@ static struct service g_irc_service = .on_data = on_data, .on_eof = NULL, .on_error = NULL, - .on_aborted = NULL + .on_stopped = NULL }; static bool diff --git a/plugins/lua-loader.c b/plugins/lua-loader.c index 013b25f..95550da 100644 --- a/plugins/lua-loader.c +++ b/plugins/lua-loader.c @@ -110,10 +110,10 @@ xlua_unit_add_info (lua_State *L) } static int -xlua_unit_abort (lua_State *L) +xlua_unit_stop (lua_State *L) { struct unit_wrapper *data = luaL_checkudata (L, 1, UNIT_METATABLE); - g_data.api->unit_abort (data->unit); + g_data.api->unit_stop (data->unit); return 0; } @@ -133,7 +133,7 @@ static luaL_Reg xlua_unit_table[] = { "write", xlua_unit_write }, { "set_success", xlua_unit_set_success }, { "add_info", xlua_unit_add_info }, - { "abort", xlua_unit_abort }, + { "stop", xlua_unit_stop }, { "__gc", xlua_unit_destroy }, { NULL, NULL } }; @@ -208,7 +208,7 @@ handle_scan_method_failure (struct scan_data *data) { print_error ("Lua: service `%s': %s", data->service->name, lua_tostring (data->L, -1)); - g_data.api->unit_abort (data->unit); + g_data.api->unit_stop (data->unit); lua_pop (data->L, 1); } @@ -273,10 +273,10 @@ on_error (void *handle) } static void -on_aborted (void *handle) +on_stopped (void *handle) { struct scan_data *data = handle; - if (!prepare_scan_method (data, "on_aborted")) + if (!prepare_scan_method (data, "on_stopped")) return; if (lua_pcall (data->L, 1, 0, 0)) handle_scan_method_failure (data); @@ -329,7 +329,7 @@ xlua_register_service (lua_State *L) s->on_data = on_data; s->on_eof = on_eof; s->on_error = on_error; - s->on_aborted = on_aborted; + s->on_stopped = on_stopped; g_data.api->register_service (g_data.ctx, s); return 0; diff --git a/plugins/mpd.lua b/plugins/mpd.lua index b513723..4735e66 100644 --- a/plugins/mpd.lua +++ b/plugins/mpd.lua @@ -34,7 +34,7 @@ function MPD:on_data (data) self.unit:add_info ("version " .. version) self.unit:set_success (true) end - self.unit:abort () + self.unit:stop () end end diff --git a/plugins/socks.lua b/plugins/socks.lua index 364eb48..ed07eff 100644 --- a/plugins/socks.lua +++ b/plugins/socks.lua @@ -38,7 +38,7 @@ function Socks4:on_data (data) if null == 0 and code >= 90 and code <= 93 then self.unit:set_success (true) end - self.unit:abort () + self.unit:stop () end end @@ -75,7 +75,7 @@ function Socks5:on_data (data) end self.unit:set_success (true) end - self.unit:abort () + self.unit:stop () end end diff --git a/plugins/ssh.c b/plugins/ssh.c index 9d233da..8ce2e08 100644 --- a/plugins/ssh.c +++ b/plugins/ssh.c @@ -77,7 +77,7 @@ on_data (void *handle, const void *data, size_t len) g_data.api->unit_set_success (scan->u, true); end_scan: - g_data.api->unit_abort (scan->u); + g_data.api->unit_stop (scan->u); } static struct service g_ssh_service = @@ -90,7 +90,7 @@ static struct service g_ssh_service = .on_data = on_data, .on_eof = NULL, .on_error = NULL, - .on_aborted = NULL + .on_stopped = NULL }; static bool @@ -204,7 +204,7 @@ struct target /// All currently running units for this target, holding a reference to us. /// They remove themselves from this list upon terminating. The purpose of - /// this list is making it possible to abort them forcefully. + /// this list is making it possible to stop them forcefully. struct unit *running_units; }; @@ -235,8 +235,8 @@ struct unit struct str_vector info; ///< Info resulting from the scan bool scan_started; ///< Whether the scan has been started - bool abortion_requested; ///< Abortion requested by service - bool aborted; ///< Scan has been aborted + bool stop_requested; ///< Stopping requested by service + bool stopped; ///< Scan has been stopped bool success; ///< Service has been found }; @@ -522,16 +522,16 @@ unit_unref (struct unit *self) } static void -unit_abort (struct unit *u) +unit_stop (struct unit *u) { - if (u->aborted) + if (u->stopped) return; - u->aborted = true; + u->stopped = true; if (u->scan_started) { - if (u->service->on_aborted) - u->service->on_aborted (u->service_data); + if (u->service->on_stopped) + u->service->on_stopped (u->service_data); u->service->scan_free (u->service_data); u->transport->cleanup (u); @@ -599,8 +599,8 @@ on_unit_ready (const struct pollfd *pfd, struct unit *u) service->on_data (u->service_data, buf->str, buf->len); str_remove_slice (buf, 0, buf->len); - if (u->abortion_requested) - goto abort; + if (u->stop_requested) + goto stop; } if ((result = transport->on_writeable (u)) == TRANSPORT_IO_ERROR) @@ -611,8 +611,8 @@ on_unit_ready (const struct pollfd *pfd, struct unit *u) { if (service->on_eof) service->on_eof (u->service_data); - if (u->abortion_requested || !u->write_buffer.len) - goto abort; + if (u->stop_requested || !u->write_buffer.len) + goto stop; } unit_update_poller (u, pfd); @@ -622,8 +622,8 @@ error: if (service->on_error) service->on_error (u->service_data); -abort: - unit_abort (u); +stop: + unit_stop (u); } static void @@ -632,7 +632,7 @@ unit_start_scan (struct unit *u) if (!u->transport->init (u)) { // TODO: maybe print a message with the problem? - unit_abort (u); + unit_stop (u); return; } @@ -663,7 +663,7 @@ on_unit_connected (const struct pollfd *pfd, struct unit *u) // But POSIX seems to say that this can block, too. soft_assert (error != EADDRNOTAVAIL); - unit_abort (u); + unit_stop (u); } else unit_start_scan (u); @@ -686,7 +686,7 @@ unit_new (struct target *target, int socket_fd, uint16_t port, str_vector_init (&u->info); poller_timer_init (&u->timeout_event, &target->ctx->poller); - u->timeout_event.dispatcher = (poller_timer_fn) unit_abort; + u->timeout_event.dispatcher = (poller_timer_fn) unit_stop; u->timeout_event.user_data = u; poller_fd_init (&u->fd_event, &target->ctx->poller, socket_fd); @@ -773,7 +773,7 @@ initiate_quit (struct app_context *ctx) for (u_iter = t_iter->running_units; u_iter; u_iter = u_next) { u_next = u_iter->next; - unit_abort (u_iter); + unit_stop (u_iter); } } @@ -813,7 +813,7 @@ plugin_api_unit_get_address (struct unit *u) static ssize_t plugin_api_unit_write (struct unit *u, const void *buf, size_t len) { - if (u->abortion_requested || u->aborted) + if (u->stop_requested || u->stopped) return -1; str_append_data (&u->write_buffer, buf, len); @@ -833,9 +833,9 @@ plugin_api_unit_add_info (struct unit *u, const char *result) } static void -plugin_api_unit_abort (struct unit *u) +plugin_api_unit_stop (struct unit *u) { - u->abortion_requested = true; + u->stop_requested = true; } static struct plugin_api g_plugin_vtable = @@ -846,7 +846,7 @@ static struct plugin_api g_plugin_vtable = .unit_write = plugin_api_unit_write, .unit_set_success = plugin_api_unit_set_success, .unit_add_info = plugin_api_unit_add_info, - .unit_abort = plugin_api_unit_abort + .unit_stop = plugin_api_unit_stop }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1546,7 +1546,7 @@ target_unref (struct target *self) if (self->results) target_dump_results (self); - // These must have been aborted already (although we could do that in here) + // These must have been stopped already (although we could do that in here) hard_assert (!self->running_units); struct unit *iter, *next; |