1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-20 14:39:02 +00:00

Don't associate nsock logging info to a nspool.

Make current loglevel and current log callback global
to the library. Attaching them to the nsock pool doesn't
bring any benefit and prevents from logging activity in
code sections that don't have access to a pool (such as
proxy chain specification parsing).

Updated external calls and nsock tests accordingly.
This commit is contained in:
henri
2015-06-27 08:21:53 +00:00
parent b75233ce98
commit b55ff2d68f
34 changed files with 222 additions and 209 deletions

View File

@@ -193,7 +193,7 @@ int nsock_event_cancel(nsock_pool ms_pool, nsock_event_id id, int notify) {
assert(nsp);
type = get_event_id_type(id);
nsock_log_info(nsp, "Event #%li (type %s) cancelled", id, nse_type2str(type));
nsock_log_info("Event #%li (type %s) cancelled", id, nse_type2str(type));
/* First we figure out what list it is in */
switch (type) {
@@ -271,7 +271,7 @@ int nevent_delete(struct npool *nsp, struct nevent *nse, gh_list_t *event_list,
return 0;
}
nsock_log_info(nsp, "%s on event #%li (type %s)", __func__, nse->id,
nsock_log_info("%s on event #%li (type %s)", __func__, nse->id,
nse_type2str(nse->type));
/* Now that we found the event... we go through the motions of cleanly
@@ -316,12 +316,12 @@ int nevent_delete(struct npool *nsp, struct nevent *nse, gh_list_t *event_list,
gh_list_append(&nsp->free_events, &nse->nodeq_io);
nsock_log_debug_all(nsp, "NSE #%lu: Removing event from list", nse->id);
nsock_log_debug_all("NSE #%lu: Removing event from list", nse->id);
#if HAVE_PCAP
#if PCAP_BSD_SELECT_HACK
if (nse->type == NSE_TYPE_PCAP_READ) {
nsock_log_debug_all(nsp, "PCAP NSE #%lu: CANCEL TEST pcap=%p read=%p curr=%p sd=%i",
nsock_log_debug_all("PCAP NSE #%lu: CANCEL TEST pcap=%p read=%p curr=%p sd=%i",
nse->id, &nsp->pcap_read_events, &nsp->read_events,
event_list,((mspcap *)nse->iod->pcap)->pcap_desc);
@@ -333,7 +333,7 @@ int nevent_delete(struct npool *nsp, struct nevent *nse, gh_list_t *event_list,
/* event is done, list is read_events and we're in BSD_HACK mode. So unlink
* event from pcap_read_events */
gh_list_remove(&nsp->pcap_read_events, &nse->nodeq_pcap);
nsock_log_debug_all(nsp, "PCAP NSE #%lu: Removing event from PCAP_READ_EVENTS", nse->id);
nsock_log_debug_all("PCAP NSE #%lu: Removing event from PCAP_READ_EVENTS", nse->id);
}
if (((mspcap *)nse->iod->pcap)->pcap_desc >= 0 && event_list == &nsp->pcap_read_events) {
@@ -341,7 +341,7 @@ int nevent_delete(struct npool *nsp, struct nevent *nse, gh_list_t *event_list,
* So unlink event from read_events */
gh_list_remove(&nsp->read_events, &nse->nodeq_io);
nsock_log_debug_all(nsp, "PCAP NSE #%lu: Removing event from READ_EVENTS", nse->id);
nsock_log_debug_all("PCAP NSE #%lu: Removing event from READ_EVENTS", nse->id);
}
}
#endif
@@ -469,9 +469,9 @@ struct nevent *event_new(struct npool *nsp, enum nse_type type,
nse->userdata = userdata;
if (nse->iod == NULL)
nsock_log_debug(nsp, "%s (IOD #NULL) (EID #%li)", __func__, nse->id);
nsock_log_debug("%s (IOD #NULL) (EID #%li)", __func__, nse->id);
else
nsock_log_debug(nsp, "%s (IOD #%li) (EID #%li)", __func__, nse->iod->id,
nsock_log_debug("%s (IOD #%li) (EID #%li)", __func__, nse->iod->id,
nse->id);
return nse;
}
@@ -482,9 +482,9 @@ struct nevent *event_new(struct npool *nsp, enum nse_type type,
* remember to do this if you call event_delete() directly */
void event_delete(struct npool *nsp, struct nevent *nse) {
if (nse->iod == NULL)
nsock_log_debug(nsp, "%s (IOD #NULL) (EID #%li)", __func__, nse->id);
nsock_log_debug("%s (IOD #NULL) (EID #%li)", __func__, nse->id);
else
nsock_log_debug(nsp, "%s (IOD #%li) (EID #%li)", __func__, nse->iod->id, nse->id);
nsock_log_debug("%s (IOD #%li) (EID #%li)", __func__, nse->iod->id, nse->id);
/* First free the IOBuf inside it if necessary */
if (nse->type == NSE_TYPE_READ || nse->type == NSE_TYPE_WRITE) {
@@ -493,7 +493,7 @@ void event_delete(struct npool *nsp, struct nevent *nse) {
#if HAVE_PCAP
if (nse->type == NSE_TYPE_PCAP_READ) {
fs_free(&nse->iobuf);
nsock_log_debug_all(nsp, "PCAP removed %lu", nse->id);
nsock_log_debug_all("PCAP removed %lu", nse->id);
}
#endif