Lines Matching refs:ts

164 	tsd_t			*ts = (tsd_t *)tsd;
171 result = prepare_socketpair(ts);
174 result = prepare_localtcp(ts);
177 result = prepare_fifos(ts);
181 result = prepare_pipes(ts);
190 result = pthread_create(&ts->ts_thread, NULL, loopback, tsd);
205 ts->ts_child = pid;
215 if (write(ts->ts_out, wbuf, opts) != opts) {
218 if (readall(ts->ts_in, rbuf, opts) != opts) {
228 tsd_t *ts = (tsd_t *)tsd;
233 if (write(ts->ts_out, wbuf, opts) != opts) {
238 n = readall(ts->ts_in, rbuf, opts);
252 tsd_t *ts = (tsd_t *)tsd;
255 (void) write(ts->ts_out, wbuf, opts);
256 (void) readall(ts->ts_in, rbuf, opts);
260 (void) close(ts->ts_in2);
261 (void) close(ts->ts_out2);
262 (void) pthread_join(ts->ts_thread, NULL);
265 (void) close(ts->ts_in2);
266 (void) close(ts->ts_out2);
267 (void) waitpid(ts->ts_child, NULL, 0);
274 (void) close(ts->ts_in);
275 (void) close(ts->ts_out);
278 (void) cleanup_fifos(ts);
316 tsd_t *ts = (tsd_t *)arg;
323 n = readall(ts->ts_in2, rbuf, opts);
327 if (write(ts->ts_out2, wbuf, opts) != opts) {
336 prepare_localtcp_once(tsd_t *ts)
344 ts->ts_lsn = socket(AF_INET, SOCK_STREAM, 0);
345 if (ts->ts_lsn == -1) {
349 if (setsockopt(ts->ts_lsn, SOL_SOCKET, SO_REUSEADDR,
359 (void) memset(&ts->ts_add, 0,
361 ts->ts_add.sin_family = AF_INET;
362 ts->ts_add.sin_port = htons(j++);
363 (void) memcpy(&ts->ts_add.sin_addr.s_addr,
366 if (bind(ts->ts_lsn,
367 (struct sockaddr *)&ts->ts_add,
377 if (listen(ts->ts_lsn, 5) == -1) {
385 prepare_localtcp(tsd_t *ts)
392 if (ts->ts_once++ == 0) {
393 if (prepare_localtcp_once(ts) == -1) {
398 ts->ts_out = socket(AF_INET, SOCK_STREAM, 0);
399 if (ts->ts_out == -1) {
403 if (fcntl(ts->ts_out, F_SETFL, O_NDELAY) == -1) {
407 result = connect(ts->ts_out, (struct sockaddr *)&ts->ts_add,
413 if (fcntl(ts->ts_out, F_SETFL, 0) == -1) {
418 result = accept(ts->ts_lsn, (struct sockaddr *)&addr, &size);
422 ts->ts_out2 = result;
424 if (setsockopt(ts->ts_out, IPPROTO_TCP, TCP_NODELAY,
429 if (setsockopt(ts->ts_out2, IPPROTO_TCP, TCP_NODELAY,
435 ts->ts_in = ts->ts_out2;
437 ts->ts_in = ts->ts_out;
438 ts->ts_in2 = ts->ts_out2;
445 prepare_socketpair(tsd_t *ts)
454 ts->ts_in = s[0];
455 ts->ts_out = s[1];
457 ts->ts_in = s[0];
458 ts->ts_out = s[0];
459 ts->ts_in2 = s[1];
460 ts->ts_out2 = s[1];
467 prepare_fifos(tsd_t *ts)
478 ts->ts_in = open(path, O_RDONLY);
479 ts->ts_out = open(path, O_WRONLY);
481 ts->ts_in = open(path, O_RDONLY);
482 ts->ts_out2 = open(path, O_WRONLY);
490 ts->ts_in2 = open(path, O_RDONLY);
491 ts->ts_out = open(path, O_WRONLY);
499 cleanup_fifos(tsd_t *ts)
512 prepare_pipes(tsd_t *ts)
520 ts->ts_in = p[0];
521 ts->ts_out = p[1];
527 ts->ts_in = p[0];
528 ts->ts_out2 = p[1];
533 ts->ts_in2 = p[0];
534 ts->ts_out = p[1];