int i;
// reversed order to save guard uninitialized access to 0 index
for (i = MAX_THREAD - 1; i >= 0; i--) {
- APPL_TRACE_DEBUG("ts[%d].used:%d", i, ts[i].used);
if (!ts[i].used) {
ts[i].used = 1;
return i;
btsock_cmd_cb cmd_callback) {
asrt(callback || cmd_callback);
int h = alloc_thread_slot();
- APPL_TRACE_DEBUG("alloc_thread_slot ret:%d", h);
if (h >= 0) {
init_poll(h);
pthread_t thread;
}
ts[h].thread_id = thread;
- APPL_TRACE_DEBUG("h:%d, thread id:%d", h, ts[h].thread_id);
ts[h].callback = callback;
ts[h].cmd_callback = cmd_callback;
}
APPL_TRACE_ERROR("socketpair failed: %s", strerror(errno));
return;
}
- APPL_TRACE_DEBUG("h:%d, cmd_fdr:%d, cmd_fdw:%d", h, ts[h].cmd_fdr,
- ts[h].cmd_fdw);
// add the cmd fd for read & write
add_poll(h, ts[h].cmd_fdr, 0, SOCK_THREAD_FD_RD, 0);
}
add_poll(h, fd, type, flags, user_id);
return true;
}
- APPL_TRACE_DEBUG(
+ LOG_WARN(
"THREAD_ADD_FD_SYNC is not called in poll thread, fallback to async");
}
sock_cmd_t cmd = {CMD_ADD_FD, fd, type, flags, user_id};
- APPL_TRACE_DEBUG("adding fd:%d, flags:0x%x", fd, flags);
ssize_t ret;
OSI_NO_INTR(ret = send(ts[h].cmd_fdw, &cmd, sizeof(cmd), 0));
return false;
}
sock_cmd_t cmd = {CMD_USER_PRIVATE, 0, type, size, user_id};
- APPL_TRACE_DEBUG("post cmd type:%d, size:%d, h:%d, ", type, size, h);
sock_cmd_t* cmd_send = &cmd;
int size_send = sizeof(cmd);
if (data && size) {
case CMD_EXIT:
return false;
default:
- APPL_TRACE_DEBUG("unknown cmd: %d", cmd.id);
+ LOG_WARN("unknown cmd: %d", cmd.id);
break;
}
return true;
if ((events)&POLLHUP) flags += " POLLHUP ";
if ((events)&POLLNVAL) flags += " POLLNVAL";
if ((events)&POLLRDHUP) flags += " POLLRDHUP";
- APPL_TRACE_DEBUG("print poll event:%x = %s", (events), flags.c_str());
+ LOG_DEBUG("print poll event:%x = %s", (events), flags.c_str());
}
static void process_data_sock(int h, struct pollfd* pfds, int count) {
{
asrt(pfds[0].fd == ts[h].cmd_fdr);
if (!process_cmd_sock(h)) {
- APPL_TRACE_DEBUG("h:%d, process_cmd_sock return false, exit...", h);
+ LOG_INFO("h:%d, process_cmd_sock return false, exit...", h);
break;
}
if (ret == 1)
}
if (need_process_data_fd) process_data_sock(h, pfds, ret);
} else {
- APPL_TRACE_DEBUG("no data, select ret: %d", ret)
+ LOG_DEBUG("no data, select ret: %d", ret);
};
}
- APPL_TRACE_DEBUG("socket poll thread exiting, h:%d", h);
+ LOG_INFO("socket poll thread exiting, h:%d", h);
return 0;
}