NMEM nmem = nmem_create();
const char *xmlrec;
char type[80];
+ yaz_log(YLOG_LOG, "Record ingest begin client=%p session=%p", cl, cl->session);
if (nativesyntax_to_type(sdb, type, rec))
yaz_log(YLOG_WARN, "Failed to determine record type");
xmlrec = ZOOM_record_get(rec, type, NULL);
client_get_url(cl));
}
nmem_destroy(nmem);
+ yaz_log(YLOG_LOG, "Record ingest end client=%p session=%p", cl, cl->session);
}
}
else
r->next = 0;
r->mutex = 0;
yaz_mutex_create(&r->mutex);
+ yaz_mutex_set_name(r->mutex, "client");
+
r->ref_count = 1;
return r;
ZOOM_connection_connect(link, host->ipport, 0);
con->link = link;
- con->iochan = iochan_create(0, connection_handler, 0);
+ con->iochan = iochan_create(0, connection_handler, 0, "connection_socket");
con->state = Conn_Connecting;
iochan_settimeout(con->iochan, con->operation_timeout);
iochan_setdata(con->iochan, con);
return 0;
}
yaz_mutex_create(&host->mutex);
+ yaz_mutex_set_name(host->mutex, "host");
return host;
}
p->hosts = 0;
p->mutex = 0;
yaz_mutex_create(&p->mutex);
+ yaz_mutex_set_name(p->mutex, "database");
return p;
}
while (c)
{
IOCHAN c_next = c->next;
+ xfree(c->name);
xfree(c);
c = c_next;
}
man->channel_list = chan;
}
-IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags)
+IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags,
+ const char *name)
{
IOCHAN new_iochan;
new_iochan->next = NULL;
new_iochan->man = 0;
new_iochan->thread_users = 0;
+ new_iochan->name = name ? xstrdup(name) : 0;
return new_iochan;
}
static void work_handler(void *work_data)
{
IOCHAN p = work_data;
+
+ yaz_log(p->man->log_level, "eventl: work begin chan=%p name=%s event=%d",
+ p, p->name ? p->name : "", p->this_event);
+
if (!p->destroyed && (p->this_event & EVENT_TIMEOUT))
(*p->fun)(p, EVENT_TIMEOUT);
if (!p->destroyed && (p->this_event & EVENT_INPUT))
(*p->fun)(p, EVENT_OUTPUT);
if (!p->destroyed && (p->this_event & EVENT_EXCEPT))
(*p->fun)(p, EVENT_EXCEPT);
+
+ yaz_log(p->man->log_level, "eventl: work end chan=%p name=%s event=%d",
+ p, p->name ? p->name : "", p->this_event);
}
static void run_fun(iochan_man_t man, IOCHAN p)
{
if (man->sel_thread)
{
- yaz_log(man->log_level, "eventl: add fun chan=%p event=%d",
- p, p->this_event);
+ yaz_log(man->log_level, "eventl: add fun chan=%p name=%s event=%d",
+ p, p->name ? p->name : "", p->this_event);
p->thread_users++;
sel_thread_add(man->sel_thread, p);
}
{
if (man->sel_fd > max)
max = man->sel_fd;
- yaz_log(man->log_level, "select on sel fd=%d", man->sel_fd);
FD_SET(man->sel_fd, &in);
}
- yaz_log(man->log_level, "select begin");
+ yaz_log(man->log_level, "select begin nofds=%d", max);
res = select(max + 1, &in, &out, &except, timeout);
yaz_log(man->log_level, "select returned res=%d", res);
if (res < 0)
man->sel_fd);
while ((chan = sel_thread_result(man->sel_thread)))
{
- yaz_log(man->log_level, "eventl: got thread result p=%p",
- chan);
+ yaz_log(man->log_level, "eventl: got thread result chan=%p name=%s",
+ chan, chan->name ? chan->name : "");
chan->thread_users--;
}
}
int force_event = p->force_event;
time_t now = time(0);
- if (p->thread_users > 0 || p->destroyed)
+ if (p->destroyed)
+ {
+ yaz_log(man->log_level, "eventl: skip destroyed chan=%p name=%s", p, p->name ? p->name : "");
+ continue;
+ }
+ if (p->thread_users > 0)
{
- yaz_log(man->log_level, "eventl: skip chan=%p users=%d", p, p->thread_users);
+ yaz_log(man->log_level, "eventl: skip chan=%p name=%s users=%d", p, p->name ? p->name : "", p->thread_users);
continue;
}
p->this_event = 0;
if (p->destroyed && p->thread_users == 0)
{
*nextp = p->next;
+ xfree(p->name);
xfree(p);
}
else
int thread_users;
iochan_man_t man;
-
+ char *name;
struct iochan *next;
} *IOCHAN;
#define iochan_setmaskfun(i, f) ((i)->maskfun = (f))
#define iochan_getmaskfun(i) ((i)->maskfun)
-IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags);
+IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags, const char *name);
#endif
/*
}
else
{
- IOCHAN chan = iochan_create(fd, iochan_handler, EVENT_INPUT);
+ IOCHAN chan = iochan_create(fd, iochan_handler, EVENT_INPUT,
+ "getaddrinfo_socket");
iochan_setdata(chan, p);
iochan_add(iochan_man, chan);
}
int host_getaddrinfo(struct host *host, iochan_man_t iochan_man)
{
struct work *w = xmalloc(sizeof(*w));
- int use_thread = 1; /* =0 to disable threading entirely */
+ int use_thread = 0; /* =0 to disable threading entirely */
w->hostport = host->hostport;
w->ipport = 0;
p->first_response = 1;
c->proxy = p;
// We will add EVENT_OUTPUT below
- p->iochan = iochan_create(sock, proxy_io, EVENT_INPUT);
+ p->iochan = iochan_create(sock, proxy_io, EVENT_INPUT, "http_proxy");
iochan_setdata(p->iochan, p);
iochan_add(ser->iochan_man, p->iochan);
enable_nonblock(s);
yaz_log(YLOG_DEBUG, "New command connection");
- c = iochan_create(s, http_io, EVENT_INPUT | EVENT_EXCEPT);
+ c = iochan_create(s, http_io, EVENT_INPUT | EVENT_EXCEPT, "http_session_socket");
ch = http_channel_create(server->http_server, inet_ntoa(addr.sin_addr),
server);
server->http_server->listener_socket = l;
- c = iochan_create(l, http_accept, EVENT_INPUT | EVENT_EXCEPT);
+ c = iochan_create(l, http_accept, EVENT_INPUT | EVENT_EXCEPT, "http_server");
iochan_setdata(c, server);
iochan_add(server->iochan_man, c);
http_sessions->session_list = r;
yaz_mutex_leave(http_sessions->mutex);
- r->timeout_iochan = iochan_create(-1, session_timeout, 0);
+ r->timeout_iochan = iochan_create(-1, session_timeout, 0, "http_session_timeout");
iochan_setdata(r->timeout_iochan, r);
yaz_log(YLOG_LOG, "timeout=%d", service->session_timeout);
iochan_settimeout(r->timeout_iochan, service->session_timeout);
nc->items = 0;
nc->mutex = 0;
yaz_mutex_create(&nc->mutex);
+ yaz_mutex_set_name(nc->mutex, "normalize_cache");
return nc;
}
res->num_records = 0;
res->mutex = 0;
yaz_mutex_create(&res->mutex);
+ yaz_mutex_set_name(res->mutex, "reclist");
return res;
}
session->normalize_cache = normalize_cache_create();
session->mutex = 0;
yaz_mutex_create(&session->mutex);
+ yaz_mutex_set_name(session->mutex, "session");
return session;
}