Lines Matching defs:ts

95 static thread_slot_t ts[MAX_THREAD];
136 APPL_TRACE_DEBUG("ts[%d].used:%d", i, ts[i].used);
137 if (!ts[i].used) {
138 ts[i].used = 1;
148 ts[h].used = 0;
159 ts[h].cmd_fdr = ts[h].cmd_fdw = -1;
160 ts[h].used = 0;
161 ts[h].thread_id = -1;
162 ts[h].poll_count = 0;
163 ts[h].callback = NULL;
164 ts[h].cmd_callback = NULL;
184 ts[h].thread_id = thread;
185 APPL_TRACE_DEBUG("h:%d, thread id:%d", h, ts[h].thread_id);
186 ts[h].callback = callback;
187 ts[h].cmd_callback = cmd_callback;
194 asrt(ts[h].cmd_fdr == -1 && ts[h].cmd_fdw == -1);
195 if (socketpair(AF_UNIX, SOCK_STREAM, 0, &ts[h].cmd_fdr) < 0) {
199 APPL_TRACE_DEBUG("h:%d, cmd_fdr:%d, cmd_fdw:%d", h, ts[h].cmd_fdr,
200 ts[h].cmd_fdw);
202 add_poll(h, ts[h].cmd_fdr, 0, SOCK_THREAD_FD_RD, 0);
205 if (ts[h].cmd_fdr != -1) {
206 close(ts[h].cmd_fdr);
207 ts[h].cmd_fdr = -1;
209 if (ts[h].cmd_fdw != -1) {
210 close(ts[h].cmd_fdw);
211 ts[h].cmd_fdw = -1;
226 if (ts[h].cmd_fdw == -1) {
233 if (ts[h].thread_id == pthread_self()) {
246 OSI_NO_INTR(ret = send(ts[h].cmd_fdw, &cmd, sizeof(cmd), 0));
264 OSI_NO_INTR(ret = send(ts[thread_handle].cmd_fdw, &cmd, sizeof(cmd), 0));
275 if (ts[h].cmd_fdw == -1) {
298 OSI_NO_INTR(ret = send(ts[h].cmd_fdw, cmd_send, size_send, 0));
307 if (ts[h].cmd_fdw == -1) {
314 OSI_NO_INTR(ret = send(ts[h].cmd_fdw, &cmd, sizeof(cmd), 0));
323 if (ts[h].cmd_fdw == -1) {
330 OSI_NO_INTR(ret = send(ts[h].cmd_fdw, &cmd, sizeof(cmd), 0));
333 if (ts[h].thread_id != -1) {
334 pthread_join(ts[h].thread_id, 0);
335 ts[h].thread_id = -1;
344 ts[h].poll_count = 0;
345 ts[h].thread_id = -1;
346 ts[h].callback = NULL;
347 ts[h].cmd_callback = NULL;
349 ts[h].ps[i].pfd.fd = -1;
350 ts[h].psi[i] = -1;
380 poll_slot_t* ps = ts[h].ps;
384 asrt(ts[h].poll_count < MAX_POLL);
392 asrt(ts[h].poll_count < MAX_POLL);
394 ++ts[h].poll_count;
402 --ts[h].poll_count;
414 int fd = ts[h].cmd_fdr;
430 poll_slot_t* poll_slot = &ts[h].ps[i];
441 asrt(ts[h].cmd_callback);
442 if (ts[h].cmd_callback)
443 ts[h].cmd_callback(fd, cmd.type, cmd.flags, cmd.user_id);
467 asrt(count <= ts[h].poll_count);
469 for (i = 1; i < ts[h].poll_count; i++) {
471 int ps_i = ts[h].psi[i];
472 asrt(pfds[i].fd == ts[h].ps[ps_i].pfd.fd);
473 uint32_t user_id = ts[h].ps[ps_i].user_id;
474 int type = ts[h].ps[ps_i].type;
486 remove_poll(h, &ts[h].ps[ps_i], ts[h].ps[ps_i].flags);
488 remove_poll(h, &ts[h].ps[ps_i],
490 if (flags) ts[h].callback(pfds[i].fd, type, flags, user_id);
499 asrt(ts[h].poll_count <= MAX_POLL);
500 memset(pfds, 0, sizeof(pfds[0]) * ts[h].poll_count);
501 while (count < ts[h].poll_count) {
505 "ts[h].poll_count:%d",
506 ps_i, MAX_POLL, count, ts[h].poll_count);
509 if (ts[h].ps[ps_i].pfd.fd >= 0) {
510 pfds[pfd_i] = ts[h].ps[ps_i].pfd;
511 ts[h].psi[pfd_i] = ps_i;
525 OSI_NO_INTR(ret = poll(pfds, ts[h].poll_count, -1));
535 asrt(pfds[0].fd == ts[h].cmd_fdr);