2 * Copyright (c) 2012 The FreeBSD Foundation
5 * This software was developed by Pawel Jakub Dawidek under sponsorship from
6 * the FreeBSD Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <config/config.h>
32 #include <sys/param.h>
33 #if defined(HAVE_SYS_ENDIAN_H) && defined(HAVE_BSWAP)
34 #include <sys/endian.h>
35 #else /* !HAVE_SYS_ENDIAN_H || !HAVE_BSWAP */
36 #ifdef HAVE_MACHINE_ENDIAN_H
37 #include <machine/endian.h>
38 #else /* !HAVE_MACHINE_ENDIAN_H */
41 #else /* !HAVE_ENDIAN_H */
42 #error "No supported endian.h"
43 #endif /* !HAVE_ENDIAN_H */
44 #endif /* !HAVE_MACHINE_ENDIAN_H */
45 #include <compat/endian.h>
46 #endif /* !HAVE_SYS_ENDIAN_H || !HAVE_BSWAP */
47 #include <sys/queue.h>
67 #include <openssl/hmac.h>
69 #ifndef HAVE_SIGTIMEDWAIT
70 #include "sigtimedwait.h"
73 #include "auditdistd.h"
81 static struct adist_config *adcfg;
82 static struct adist_host *adhost;
84 static pthread_rwlock_t adist_remote_lock;
85 static pthread_mutex_t adist_remote_mtx;
86 static pthread_cond_t adist_remote_cond;
87 static struct trail *adist_trail;
89 static TAILQ_HEAD(, adreq) adist_free_list;
90 static pthread_mutex_t adist_free_list_lock;
91 static pthread_cond_t adist_free_list_cond;
92 static TAILQ_HEAD(, adreq) adist_send_list;
93 static pthread_mutex_t adist_send_list_lock;
94 static pthread_cond_t adist_send_list_cond;
95 static TAILQ_HEAD(, adreq) adist_recv_list;
96 static pthread_mutex_t adist_recv_list_lock;
97 static pthread_cond_t adist_recv_list_cond;
100 init_environment(void)
105 rw_init(&adist_remote_lock);
106 mtx_init(&adist_remote_mtx);
107 cv_init(&adist_remote_cond);
108 TAILQ_INIT(&adist_free_list);
109 mtx_init(&adist_free_list_lock);
110 cv_init(&adist_free_list_cond);
111 TAILQ_INIT(&adist_send_list);
112 mtx_init(&adist_send_list_lock);
113 cv_init(&adist_send_list_cond);
114 TAILQ_INIT(&adist_recv_list);
115 mtx_init(&adist_recv_list_lock);
116 cv_init(&adist_recv_list_cond);
118 for (ii = 0; ii < ADIST_QUEUE_SIZE; ii++) {
119 adreq = malloc(sizeof(*adreq) + ADIST_BUF_SIZE);
121 pjdlog_exitx(EX_TEMPFAIL,
122 "Unable to allocate %zu bytes of memory for adreq object.",
123 sizeof(*adreq) + ADIST_BUF_SIZE);
125 adreq->adr_byteorder = ADIST_BYTEORDER;
126 adreq->adr_cmd = ADIST_CMD_UNDEFINED;
128 adreq->adr_datasize = 0;
129 TAILQ_INSERT_TAIL(&adist_free_list, adreq, adr_next);
136 unsigned char rnd[32], hash[32], resp[32];
137 struct proto_conn *conn;
142 if (proto_send(adhost->adh_conn, &val, sizeof(val)) < 0) {
143 pjdlog_exit(EX_TEMPFAIL,
144 "Unable to send connection request to parent");
146 if (proto_recv(adhost->adh_conn, &val, sizeof(val)) < 0) {
147 pjdlog_exit(EX_TEMPFAIL,
148 "Unable to receive reply to connection request from parent");
152 pjdlog_errno(LOG_WARNING, "Unable to connect to %s",
153 adhost->adh_remoteaddr);
156 if (proto_connection_recv(adhost->adh_conn, true, &conn) < 0) {
157 pjdlog_exit(EX_TEMPFAIL,
158 "Unable to receive connection from parent");
160 if (proto_connect_wait(conn, adcfg->adc_timeout) < 0) {
161 pjdlog_errno(LOG_WARNING, "Unable to connect to %s",
162 adhost->adh_remoteaddr);
166 pjdlog_debug(1, "Connected to %s.", adhost->adh_remoteaddr);
167 /* Error in setting timeout is not critical, but why should it fail? */
168 if (proto_timeout(conn, adcfg->adc_timeout) < 0)
169 pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");
171 pjdlog_debug(1, "Timeout set to %d.", adcfg->adc_timeout);
173 /* Exchange welcome message, which includes version number. */
174 (void)snprintf(welcome, sizeof(welcome), "ADIST%02d", ADIST_VERSION);
175 if (proto_send(conn, welcome, sizeof(welcome)) < 0) {
176 pjdlog_errno(LOG_WARNING,
177 "Unable to send welcome message to %s",
178 adhost->adh_remoteaddr);
182 pjdlog_debug(1, "Welcome message sent (%s).", welcome);
183 bzero(welcome, sizeof(welcome));
184 if (proto_recv(conn, welcome, sizeof(welcome)) < 0) {
185 pjdlog_errno(LOG_WARNING,
186 "Unable to receive welcome message from %s",
187 adhost->adh_remoteaddr);
191 if (strncmp(welcome, "ADIST", 5) != 0 || !isdigit(welcome[5]) ||
192 !isdigit(welcome[6]) || welcome[7] != '\0') {
193 pjdlog_warning("Invalid welcome message from %s.",
194 adhost->adh_remoteaddr);
198 pjdlog_debug(1, "Welcome message received (%s).", welcome);
200 * Receiver can only reply with version number lower or equal to
203 adhost->adh_version = atoi(welcome + 5);
204 if (adhost->adh_version > ADIST_VERSION) {
205 pjdlog_warning("Invalid version number from %s (%d received, up to %d supported).",
206 adhost->adh_remoteaddr, adhost->adh_version, ADIST_VERSION);
211 pjdlog_debug(1, "Version %d negotiated with %s.", adhost->adh_version,
212 adhost->adh_remoteaddr);
214 if (proto_send(conn, adcfg->adc_name, sizeof(adcfg->adc_name)) == -1) {
215 pjdlog_errno(LOG_WARNING, "Unable to send name to %s",
216 adhost->adh_remoteaddr);
220 pjdlog_debug(1, "Name (%s) sent.", adcfg->adc_name);
222 if (proto_recv(conn, rnd, sizeof(rnd)) == -1) {
223 pjdlog_errno(LOG_WARNING, "Unable to receive challenge from %s",
224 adhost->adh_remoteaddr);
228 pjdlog_debug(1, "Challenge received.");
230 if (HMAC(EVP_sha256(), adhost->adh_password,
231 (int)strlen(adhost->adh_password), rnd, (int)sizeof(rnd), hash,
233 pjdlog_warning("Unable to generate response.");
237 pjdlog_debug(1, "Response generated.");
239 if (proto_send(conn, hash, sizeof(hash)) == -1) {
240 pjdlog_errno(LOG_WARNING, "Unable to send response to %s",
241 adhost->adh_remoteaddr);
245 pjdlog_debug(1, "Response sent.");
247 if (adist_random(rnd, sizeof(rnd)) == -1) {
248 pjdlog_warning("Unable to generate challenge.");
252 pjdlog_debug(1, "Challenge generated.");
254 if (proto_send(conn, rnd, sizeof(rnd)) == -1) {
255 pjdlog_errno(LOG_WARNING, "Unable to send challenge to %s",
256 adhost->adh_remoteaddr);
260 pjdlog_debug(1, "Challenge sent.");
262 if (proto_recv(conn, resp, sizeof(resp)) == -1) {
263 pjdlog_errno(LOG_WARNING, "Unable to receive response from %s",
264 adhost->adh_remoteaddr);
268 pjdlog_debug(1, "Response received.");
270 if (HMAC(EVP_sha256(), adhost->adh_password,
271 (int)strlen(adhost->adh_password), rnd, (int)sizeof(rnd), hash,
273 pjdlog_warning("Unable to generate hash.");
277 pjdlog_debug(1, "Hash generated.");
279 if (memcmp(resp, hash, sizeof(hash)) != 0) {
280 pjdlog_warning("Invalid response from %s (wrong password?).",
281 adhost->adh_remoteaddr);
285 pjdlog_info("Receiver authenticated.");
287 if (proto_recv(conn, &adhost->adh_trail_offset,
288 sizeof(adhost->adh_trail_offset)) == -1) {
289 pjdlog_errno(LOG_WARNING,
290 "Unable to receive size of the most recent trail file from %s",
291 adhost->adh_remoteaddr);
295 adhost->adh_trail_offset = le64toh(adhost->adh_trail_offset);
296 if (proto_recv(conn, &adhost->adh_trail_name,
297 sizeof(adhost->adh_trail_name)) == -1) {
298 pjdlog_errno(LOG_WARNING,
299 "Unable to receive name of the most recent trail file from %s",
300 adhost->adh_remoteaddr);
304 pjdlog_debug(1, "Trail name (%s) and offset (%ju) received.",
305 adhost->adh_trail_name, (uintmax_t)adhost->adh_trail_offset);
307 rw_wlock(&adist_remote_lock);
308 mtx_lock(&adist_remote_mtx);
309 PJDLOG_ASSERT(adhost->adh_remote == NULL);
310 PJDLOG_ASSERT(conn != NULL);
311 adhost->adh_remote = conn;
312 mtx_unlock(&adist_remote_mtx);
313 rw_unlock(&adist_remote_lock);
314 cv_signal(&adist_remote_cond);
320 sender_disconnect(void)
323 rw_wlock(&adist_remote_lock);
325 * Check for a race between dropping rlock and acquiring wlock -
326 * another thread can close connection in-between.
328 if (adhost->adh_remote == NULL) {
329 rw_unlock(&adist_remote_lock);
332 pjdlog_debug(2, "Closing connection to %s.", adhost->adh_remoteaddr);
333 proto_close(adhost->adh_remote);
334 mtx_lock(&adist_remote_mtx);
335 adhost->adh_remote = NULL;
336 adhost->adh_reset = true;
337 adhost->adh_trail_name[0] = '\0';
338 adhost->adh_trail_offset = 0;
339 mtx_unlock(&adist_remote_mtx);
340 rw_unlock(&adist_remote_lock);
342 pjdlog_warning("Disconnected from %s.", adhost->adh_remoteaddr);
344 /* Move all in-flight requests back onto free list. */
345 mtx_lock(&adist_free_list_lock);
346 mtx_lock(&adist_send_list_lock);
347 TAILQ_CONCAT(&adist_free_list, &adist_send_list, adr_next);
348 mtx_unlock(&adist_send_list_lock);
349 mtx_lock(&adist_recv_list_lock);
350 TAILQ_CONCAT(&adist_free_list, &adist_recv_list, adr_next);
351 mtx_unlock(&adist_recv_list_lock);
352 mtx_unlock(&adist_free_list_lock);
356 adreq_fill(struct adreq *adreq, uint8_t cmd, const unsigned char *data,
359 static uint64_t seq = 1;
361 PJDLOG_ASSERT(size <= ADIST_BUF_SIZE);
365 case ADIST_CMD_CLOSE:
366 PJDLOG_ASSERT(data != NULL && size == 0);
367 size = strlen(data) + 1;
369 case ADIST_CMD_APPEND:
370 PJDLOG_ASSERT(data != NULL && size > 0);
372 case ADIST_CMD_KEEPALIVE:
373 case ADIST_CMD_ERROR:
374 PJDLOG_ASSERT(data == NULL && size == 0);
377 PJDLOG_ABORT("Invalid command (%hhu).", cmd);
380 adreq->adr_cmd = cmd;
381 adreq->adr_seq = seq++;
382 adreq->adr_datasize = size;
383 /* Don't copy if data is already in out buffer. */
384 if (data != NULL && data != adreq->adr_data)
385 bcopy(data, adreq->adr_data, size);
389 read_thread_wait(void)
391 bool newfile = false;
393 mtx_lock(&adist_remote_mtx);
394 if (adhost->adh_reset) {
396 adhost->adh_reset = false;
397 if (trail_filefd(adist_trail) != -1)
398 trail_close(adist_trail);
399 trail_reset(adist_trail);
400 while (adhost->adh_remote == NULL)
401 cv_wait(&adist_remote_cond, &adist_remote_mtx);
402 trail_start(adist_trail, adhost->adh_trail_name,
403 adhost->adh_trail_offset);
406 mtx_unlock(&adist_remote_mtx);
407 while (trail_filefd(adist_trail) == -1) {
411 * We may have been disconnected and reconnected in the
412 * meantime, check if reset is set.
414 mtx_lock(&adist_remote_mtx);
415 if (adhost->adh_reset)
417 mtx_unlock(&adist_remote_mtx);
418 if (trail_filefd(adist_trail) == -1)
419 trail_next(adist_trail);
422 pjdlog_debug(1, "Trail file \"%s/%s\" opened.",
423 adhost->adh_directory,
424 trail_filename(adist_trail));
425 (void)wait_for_file_init(trail_filefd(adist_trail));
431 read_thread(void *arg __unused)
437 pjdlog_debug(1, "%s started.", __func__);
440 newfile = read_thread_wait();
441 QUEUE_TAKE(adreq, &adist_free_list, 0);
443 adreq_fill(adreq, ADIST_CMD_OPEN,
444 trail_filename(adist_trail), 0);
449 done = read(trail_filefd(adist_trail), adreq->adr_data,
456 offset = lseek(trail_filefd(adist_trail), 0, SEEK_CUR);
458 pjdlog_errno(LOG_ERR,
459 "Error while reading \"%s/%s\" at offset %jd",
460 adhost->adh_directory, trail_filename(adist_trail),
462 trail_close(adist_trail);
463 adreq_fill(adreq, ADIST_CMD_ERROR, NULL, 0);
465 } else if (done == 0) {
467 pjdlog_debug(3, "End of \"%s/%s\".",
468 adhost->adh_directory, trail_filename(adist_trail));
469 if (!trail_switch(adist_trail)) {
470 /* More audit records can arrive. */
471 mtx_lock(&adist_free_list_lock);
472 TAILQ_INSERT_TAIL(&adist_free_list, adreq,
474 mtx_unlock(&adist_free_list_lock);
478 adreq_fill(adreq, ADIST_CMD_CLOSE,
479 trail_filename(adist_trail), 0);
480 trail_close(adist_trail);
484 adreq_fill(adreq, ADIST_CMD_APPEND, adreq->adr_data, done);
487 "read thread: Moving request %p to the send queue (%hhu).",
488 adreq, adreq->adr_cmd);
489 QUEUE_INSERT(adreq, &adist_send_list);
500 rw_rlock(&adist_remote_lock);
501 if (adhost->adh_remote == NULL) {
502 rw_unlock(&adist_remote_lock);
505 rw_unlock(&adist_remote_lock);
507 mtx_lock(&adist_free_list_lock);
508 adreq = TAILQ_FIRST(&adist_free_list);
510 TAILQ_REMOVE(&adist_free_list, adreq, adr_next);
511 mtx_unlock(&adist_free_list_lock);
515 adreq_fill(adreq, ADIST_CMD_KEEPALIVE, NULL, 0);
517 QUEUE_INSERT(adreq, &adist_send_list);
519 pjdlog_debug(3, "keepalive_send: Request sent.");
523 * Thread sends request to secondary node.
526 send_thread(void *arg __unused)
528 time_t lastcheck, now;
531 pjdlog_debug(1, "%s started.", __func__);
533 lastcheck = time(NULL);
536 pjdlog_debug(3, "send thread: Taking request.");
538 QUEUE_TAKE(adreq, &adist_send_list, ADIST_KEEPALIVE);
542 if (lastcheck + ADIST_KEEPALIVE <= now) {
547 PJDLOG_ASSERT(adreq != NULL);
548 pjdlog_debug(3, "send thread: (%p) Got request %hhu.", adreq,
551 * Protect connection from disappearing.
553 rw_rlock(&adist_remote_lock);
555 * Move the request to the recv queue first to avoid race
556 * where the recv thread receives the reply before we move
557 * the request to the recv queue.
559 QUEUE_INSERT(adreq, &adist_recv_list);
560 if (adhost->adh_remote == NULL ||
561 proto_send(adhost->adh_remote, &adreq->adr_packet,
562 ADPKT_SIZE(adreq)) == -1) {
563 rw_unlock(&adist_remote_lock);
565 "send thread: (%p) Unable to send request.", adreq);
566 if (adhost->adh_remote != NULL)
570 pjdlog_debug(3, "Request %p sent successfully.", adreq);
571 adreq_log(LOG_DEBUG, 2, -1, adreq,
572 "send: (%p) Request sent: ", adreq);
573 rw_unlock(&adist_remote_lock);
581 adrep_decode_header(struct adrep *adrep)
584 /* Byte-swap only is the receiver is using different byte order. */
585 if (adrep->adrp_byteorder != ADIST_BYTEORDER) {
586 adrep->adrp_byteorder = ADIST_BYTEORDER;
587 adrep->adrp_seq = bswap64(adrep->adrp_seq);
588 adrep->adrp_error = bswap16(adrep->adrp_error);
593 * Thread receives answer from secondary node and passes it to ggate_send
597 recv_thread(void *arg __unused)
602 pjdlog_debug(1, "%s started.", __func__);
605 /* Wait until there is anything to receive. */
606 QUEUE_WAIT(&adist_recv_list);
607 pjdlog_debug(3, "recv thread: Got something.");
608 rw_rlock(&adist_remote_lock);
609 if (adhost->adh_remote == NULL) {
611 * Connection is dead.
612 * XXX: We shouldn't be here.
614 rw_unlock(&adist_remote_lock);
617 if (proto_recv(adhost->adh_remote, &adrep,
618 sizeof(adrep)) == -1) {
619 rw_unlock(&adist_remote_lock);
620 pjdlog_errno(LOG_ERR, "Unable to receive reply");
624 rw_unlock(&adist_remote_lock);
625 adrep_decode_header(&adrep);
627 * Find the request that was just confirmed.
629 mtx_lock(&adist_recv_list_lock);
630 TAILQ_FOREACH(adreq, &adist_recv_list, adr_next) {
631 if (adreq->adr_seq == adrep.adrp_seq) {
632 TAILQ_REMOVE(&adist_recv_list, adreq,
639 * If we disconnected in the meantime, just continue.
640 * On disconnect sender_disconnect() clears the queue,
643 if (TAILQ_EMPTY(&adist_recv_list)) {
644 rw_unlock(&adist_remote_lock);
647 mtx_unlock(&adist_recv_list_lock);
648 pjdlog_error("Found no request matching received 'seq' field (%ju).",
649 (uintmax_t)adrep.adrp_seq);
653 mtx_unlock(&adist_recv_list_lock);
654 adreq_log(LOG_DEBUG, 2, -1, adreq,
655 "recv thread: (%p) Request confirmed: ", adreq);
656 pjdlog_debug(3, "recv thread: (%p) Got request %hhu.", adreq,
658 if (adrep.adrp_error != 0) {
659 pjdlog_error("Receiver returned error (%s), disconnecting.",
660 adist_errstr((int)adrep.adrp_error));
664 if (adreq->adr_cmd == ADIST_CMD_CLOSE)
665 trail_unlink(adist_trail, adreq->adr_data);
666 pjdlog_debug(3, "Request received successfully.");
667 QUEUE_INSERT(adreq, &adist_free_list);
674 guard_check_connection(void)
677 PJDLOG_ASSERT(adhost->adh_role == ADIST_ROLE_SENDER);
679 rw_rlock(&adist_remote_lock);
680 if (adhost->adh_remote != NULL) {
681 rw_unlock(&adist_remote_lock);
682 pjdlog_debug(3, "remote_guard: Connection to %s is ok.",
683 adhost->adh_remoteaddr);
688 * Upgrade the lock. It doesn't have to be atomic as no other thread
689 * can change connection status from disconnected to connected.
691 rw_unlock(&adist_remote_lock);
692 pjdlog_debug(1, "remote_guard: Reconnecting to %s.",
693 adhost->adh_remoteaddr);
694 if (sender_connect() == 0) {
695 pjdlog_info("Successfully reconnected to %s.",
696 adhost->adh_remoteaddr);
698 pjdlog_debug(1, "remote_guard: Reconnect to %s failed.",
699 adhost->adh_remoteaddr);
704 * Thread guards remote connections and reconnects when needed, handles
708 guard_thread(void *arg __unused)
710 struct timespec timeout;
711 time_t lastcheck, now;
715 lastcheck = time(NULL);
717 PJDLOG_VERIFY(sigemptyset(&mask) == 0);
718 PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0);
719 PJDLOG_VERIFY(sigaddset(&mask, SIGTERM) == 0);
721 timeout.tv_sec = ADIST_KEEPALIVE;
729 sigexit_received = true;
731 "Termination signal received, exiting.");
737 pjdlog_debug(3, "remote_guard: Checking connections.");
739 if (lastcheck + ADIST_KEEPALIVE <= now) {
740 guard_check_connection();
743 signo = sigtimedwait(&mask, NULL, &timeout);
750 adist_sender(struct adist_config *config, struct adist_host *adh)
754 int error, mode, debuglevel;
757 * Create communication channel for sending connection requests from
760 if (proto_connect(NULL, "socketpair://", -1, &adh->adh_conn) == -1) {
761 pjdlog_errno(LOG_ERR,
762 "Unable to create connection sockets between child and parent");
768 pjdlog_errno(LOG_ERR, "Unable to fork");
769 proto_close(adh->adh_conn);
770 adh->adh_conn = NULL;
775 /* This is parent. */
776 adh->adh_worker_pid = pid;
777 /* Declare that we are receiver. */
778 proto_recv(adh->adh_conn, NULL, 0);
785 mode = pjdlog_mode_get();
786 debuglevel = pjdlog_debug_get();
788 /* Declare that we are sender. */
789 proto_send(adhost->adh_conn, NULL, 0);
791 descriptors_cleanup(adhost);
794 descriptors_assert(adhost, mode);
798 pjdlog_debug_set(debuglevel);
799 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
800 role2str(adhost->adh_role));
801 #ifdef HAVE_SETPROCTITLE
802 setproctitle("[%s] (%s) ", adhost->adh_name,
803 role2str(adhost->adh_role));
807 * The sender process should be able to remove entries from its
808 * trail directory, but it should not be able to write to the
809 * trail files, only read from them.
811 adist_trail = trail_new(adhost->adh_directory, false);
812 if (adist_trail == NULL)
815 if (sandbox(ADIST_USER, true, "auditdistd: %s (%s)",
816 role2str(adhost->adh_role), adhost->adh_name) != 0) {
819 pjdlog_info("Privileges successfully dropped.");
822 * We can ignore wait_for_dir_init() failures. It will fall back to
825 (void)wait_for_dir_init(trail_dirfd(adist_trail));
828 if (sender_connect() == 0) {
829 pjdlog_info("Successfully connected to %s.",
830 adhost->adh_remoteaddr);
832 adhost->adh_reset = true;
835 * Create the guard thread first, so we can handle signals from the
838 error = pthread_create(&td, NULL, guard_thread, NULL);
839 PJDLOG_ASSERT(error == 0);
840 error = pthread_create(&td, NULL, send_thread, NULL);
841 PJDLOG_ASSERT(error == 0);
842 error = pthread_create(&td, NULL, recv_thread, NULL);
843 PJDLOG_ASSERT(error == 0);
844 (void)read_thread(NULL);