2 * detail.c Process the detail file
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * Copyright 2007 The FreeRADIUS server project
21 * Copyright 2007 Alan DeKok <aland@deployingradius.com>
26 #include <freeradius-devel/radiusd.h>
27 #include <freeradius-devel/modules.h>
28 #include <freeradius-devel/detail.h>
29 #include <freeradius-devel/process.h>
30 #include <freeradius-devel/rad_assert.h>
32 #ifdef HAVE_SYS_STAT_H
44 extern bool check_config;
46 #define USEC (1000000)
48 static FR_NAME_NUMBER state_names[] = {
49 { "unopened", STATE_UNOPENED },
50 { "unlocked", STATE_UNLOCKED },
51 { "header", STATE_HEADER },
52 { "reading", STATE_READING },
53 { "queued", STATE_QUEUED },
54 { "running", STATE_RUNNING },
55 { "no-reply", STATE_NO_REPLY },
56 { "replied", STATE_REPLIED },
63 * If we're limiting outstanding packets, then mark the response
66 int detail_send(rad_listen_t *listener, REQUEST *request)
68 #ifdef WITH_DETAIL_THREAD
71 listen_detail_t *data = listener->data;
73 rad_assert(request->listener == listener);
74 rad_assert(listener->send == detail_send);
77 * This request timed out. Remember that, and tell the
78 * caller it's OK to read more "detail" file stuff.
80 if (request->reply->code == 0) {
81 data->delay_time = data->retry_interval * USEC;
83 data->state = STATE_NO_REPLY;
85 RDEBUG("Detail - No response configured for request %d. Will retry in %d seconds",
86 request->number, data->retry_interval);
91 * We call gettimeofday a lot. But it should be OK,
92 * because there's nothing else to do.
94 gettimeofday(&now, NULL);
97 * If we haven't sent a packet in the last second, reset
101 if (timercmp(&data->last_packet, &now, <)) {
102 data->has_rtt = false;
107 * Only one detail packet may be outstanding at a time,
108 * so it's safe to update some entries in the detail
111 * We keep smoothed round trip time (SRTT), but not round
112 * trip timeout (RTO). We use SRTT to calculate a rough
115 rtt = now.tv_sec - request->packet->timestamp.tv_sec;
118 rtt -= request->packet->timestamp.tv_usec;
121 * If we're proxying, the RTT is our processing time,
122 * plus the network delay there and back, plus the time
123 * on the other end to process the packet. Ideally, we
124 * should remove the network delays from the RTT, but we
125 * don't know what they are.
127 * So, to be safe, we over-estimate the total cost of
128 * processing the packet.
130 if (!data->has_rtt) {
131 data->has_rtt = true;
133 data->rttvar = rtt / 2;
136 data->rttvar -= data->rttvar >> 2;
137 data->rttvar += (data->srtt - rtt);
138 data->srtt -= data->srtt >> 3;
139 data->srtt += rtt >> 3;
143 * Calculate the time we wait before sending the next
146 * rtt / (rtt + delay) = load_factor / 100
148 data->delay_time = (data->srtt * (100 - data->load_factor)) / (data->load_factor);
151 * Cap delay at no less than 4 packets/s. If the
152 * end system can't handle this, then it's very
155 if (data->delay_time > (USEC / 4)) data->delay_time= USEC / 4;
157 RDEBUG3("Received response for request %d. Will read the next packet in %d seconds",
158 request->number, data->delay_time / USEC);
160 data->last_packet = now;
162 data->state = STATE_REPLIED;
166 #ifdef WITH_DETAIL_THREAD
167 if (write(data->child_pipe[1], &c, 1) < 0) {
168 ERROR("Failed writing ack to reader thread: %s", fr_syserror(errno));
171 radius_signal_self(RADIUS_SIGNAL_SELF_DETAIL);
179 * Open the detail file, if we can.
181 * FIXME: create it, if it's not already there, so that the main
182 * server select() will wake us up if there's anything to read.
184 static int detail_open(rad_listen_t *this)
187 listen_detail_t *data = this->data;
189 rad_assert(data->state == STATE_UNOPENED);
190 data->delay_time = USEC;
193 * Open detail.work first, so we don't lose
194 * accounting packets. It's probably better to
195 * duplicate them than to lose them.
197 * Note that we're not writing to the file, but
198 * we've got to open it for writing in order to
199 * establish the lock, to prevent rlm_detail from
202 * This also means that if we're doing globbing,
203 * this file will be read && processed before the
204 * file globbing is done.
206 data->work_fd = open(data->filename_work, O_RDWR);
207 if (data->work_fd < 0) {
214 char const *filename;
217 DEBUG2("Polling for detail file %s", data->filename);
219 memset(&files, 0, sizeof(files));
220 if (glob(data->filename, 0, NULL, &files) != 0) {
227 * Loop over the glob'd files, looking for the
232 for (i = 0; i < files.gl_pathc; i++) {
233 if (stat(files.gl_pathv[i], &st) < 0) continue;
235 if ((i == 0) || (st.st_ctime < chtime)) {
236 chtime = st.st_ctime;
241 if (found < 0) goto noop;
244 * Rename detail to detail.work
246 filename = files.gl_pathv[found];
248 DEBUG("Detail - Renaming %s -> %s", filename, data->filename_work);
249 if (rename(filename, data->filename_work) < 0) {
250 ERROR("Detail - Failed renaming %s to %s: %s",
251 filename, data->filename_work, fr_syserror(errno));
255 globfree(&files); /* Shouldn't be using anything in files now */
258 * And try to open the filename.
260 data->work_fd = open(data->filename_work, O_RDWR);
261 if (data->work_fd < 0) return 0;
263 } /* else detail.work existed, and we opened it */
265 rad_assert(data->vps == NULL);
266 rad_assert(data->fp == NULL);
268 data->state = STATE_UNLOCKED;
270 data->client_ip.af = AF_UNSPEC;
281 * FIXME: add a configuration "exit when done" so that the detail
282 * file reader can be used as a one-off tool to update stuff.
284 * The time sequence for reading from the detail file is:
286 * t_0 signalled that the server is idle, and we
287 * can read from the detail file.
289 * t_rtt the packet has been processed successfully,
290 * wait for t_delay to enforce load factor.
292 * t_rtt + t_delay wait for signal that the server is idle.
295 #ifndef WITH_DETAIL_THREAD
296 static RADIUS_PACKET *detail_poll(rad_listen_t *listener);
298 int detail_recv(rad_listen_t *listener)
300 RADIUS_PACKET *packet;
301 listen_detail_t *data = listener->data;
304 * We may be in the main thread. It needs to update the
305 * timers before we try to read from the file again.
307 if (data->signal) return 0;
309 packet = detail_poll(listener);
310 if (!packet) return -1;
313 * Don't bother doing limit checks, etc.
315 if (!request_receive(listener, packet, &data->detail_client,
318 data->state = STATE_NO_REPLY; /* try again later */
325 int detail_recv(rad_listen_t *listener)
328 RADIUS_PACKET *packet;
329 listen_detail_t *data = listener->data;
332 * Block until there's a packet ready.
334 rcode = read(data->master_pipe[0], &packet, sizeof(packet));
335 if (rcode <= 0) return rcode;
337 rad_assert(packet != NULL);
339 if (!request_receive(listener, packet, &data->detail_client,
343 data->state = STATE_NO_REPLY; /* try again later */
344 if (write(data->child_pipe[1], &c, 1) < 0) {
345 ERROR("Failed writing ack to reader thread: %s", fr_syserror(errno));
350 * Wait for the child thread to write an answer to the pipe
356 static RADIUS_PACKET *detail_poll(rad_listen_t *listener)
358 char key[256], op[8], value[1024];
361 RADIUS_PACKET *packet;
363 listen_detail_t *data = listener->data;
365 switch (data->state) {
368 rad_assert(data->work_fd < 0);
370 if (!detail_open(listener)) return NULL;
372 rad_assert(data->state == STATE_UNLOCKED);
373 rad_assert(data->work_fd >= 0);
378 * Try to lock fd. If we can't, return.
379 * If we can, continue. This means that
380 * the server doesn't block while waiting
381 * for the lock to open...
385 * Note that we do NOT block waiting for
386 * the lock. We've re-named the file
387 * above, so we've already guaranteed
388 * that any *new* detail writer will not
389 * be opening this file. The only
390 * purpose of the lock is to catch a race
391 * condition where the execution
392 * "ping-pongs" between radiusd &
395 if (rad_lockfd_nonblock(data->work_fd, 0) < 0) {
397 * Close the FD. The main loop
398 * will wake up in a second and
401 close(data->work_fd);
403 data->state = STATE_UNOPENED;
407 data->fp = fdopen(data->work_fd, "r");
409 ERROR("FATAL: Failed to re-open detail file %s: %s",
410 data->filename, fr_syserror(errno));
415 * Look for the header
417 data->state = STATE_HEADER;
418 data->delay_time = USEC;
427 data->state = STATE_UNOPENED;
434 if (fstat(data->work_fd, &buf) < 0) {
435 ERROR("Failed to stat "
436 "detail file %s: %s",
442 if (((off_t) ftell(data->fp)) == buf.st_size) {
448 * End of file. Delete it, and re-set
451 if (feof(data->fp)) {
453 DEBUG("Detail - unlinking %s",
454 data->filename_work);
455 unlink(data->filename_work);
456 if (data->fp) fclose(data->fp);
459 data->state = STATE_UNOPENED;
460 rad_assert(data->vps == NULL);
462 if (data->one_shot) {
463 INFO("Finished reading \"one shot\" detail file - Exiting");
464 radius_signal_self(RADIUS_SIGNAL_SELF_EXIT);
471 * Else go read something.
476 * Read more value-pair's, unless we're
477 * at EOF. In that case, queue whatever
481 if (data->fp && !feof(data->fp)) break;
482 data->state = STATE_QUEUED;
490 * Periodically check what's going on.
491 * If the request is taking too long,
495 if (time(NULL) < (data->running + (int)data->retry_interval)) {
499 DEBUG("No response to detail request. Retrying");
503 * If there's no reply, keep
504 * retransmitting the current packet
508 data->state = STATE_QUEUED;
512 * We have a reply. Clean up the old
513 * request, and go read another one.
516 pairfree(&data->vps);
517 data->state = STATE_HEADER;
521 fr_cursor_init(&cursor, &data->vps);
524 * Read a header, OR a value-pair.
526 while (fgets(buffer, sizeof(buffer), data->fp)) {
527 data->offset = ftell(data->fp); /* for statistics */
530 * Badly formatted file: delete it.
532 * FIXME: Maybe flag an error?
534 if (!strchr(buffer, '\n')) {
535 pairfree(&data->vps);
540 * We're reading VP's, and got a blank line.
543 if ((data->state == STATE_READING) &&
544 (buffer[0] == '\n')) {
545 data->state = STATE_QUEUED;
550 * Look for date/time header, and read VP's if
551 * found. If not, keep reading lines until we
554 if (data->state == STATE_HEADER) {
557 if (sscanf(buffer, "%*s %*s %*d %*d:%*d:%*d %d", &y)) {
558 data->state = STATE_READING;
564 * We have a full "attribute = value" line.
565 * If it doesn't look reasonable, skip it.
567 * FIXME: print an error for badly formatted attributes?
569 if (sscanf(buffer, "%255s %7s %1023s", key, op, value) != 3) {
570 WARN("Skipping badly formatted line %s",
576 * Should be =, :=, +=, ...
578 if (!strchr(op, '=')) continue;
581 * Skip non-protocol attributes.
583 if (!strcasecmp(key, "Request-Authenticator")) continue;
586 * Set the original client IP address, based on
587 * what's in the detail file.
589 * Hmm... we don't set the server IP address.
592 if (!strcasecmp(key, "Client-IP-Address")) {
593 data->client_ip.af = AF_INET;
594 if (ip_hton(&data->client_ip, AF_INET, value, false) < 0) {
595 ERROR("Failed parsing Client-IP-Address");
597 pairfree(&data->vps);
604 * The original time at which we received the
605 * packet. We need this to properly calculate
608 if (!strcasecmp(key, "Timestamp")) {
609 data->timestamp = atoi(value);
611 vp = paircreate(data, PW_PACKET_ORIGINAL_TIMESTAMP, 0);
613 vp->vp_date = (uint32_t) data->timestamp;
615 fr_cursor_insert(&cursor, vp);
623 * FIXME: do we want to check for non-protocol
624 * attributes like radsqlrelay does?
627 if ((userparse(data, buffer, &vp) > 0) &&
629 fr_cursor_insert(&cursor, vp);
634 * Some kind of error.
636 * FIXME: Leave the file in-place, and warn the
639 if (ferror(data->fp)) goto cleanup;
645 * Process the packet.
651 * The writer doesn't check that the record was
652 * completely written. If the disk is full, this can
653 * result in a truncated record. When that happens,
656 if (data->state != STATE_QUEUED) {
657 ERROR("Truncated record: treating it as EOF for detail file %s", data->filename_work);
662 * We're done reading the file, but we didn't read
663 * anything. Clean up, and don't return anything.
666 data->state = STATE_HEADER;
667 if (!data->fp || feof(data->fp)) goto cleanup;
672 * Allocate the packet. If we fail, it's a serious
675 packet = rad_alloc(NULL, true);
677 ERROR("FATAL: Failed allocating memory for detail");
682 memset(packet, 0, sizeof(*packet));
684 packet->src_ipaddr.af = AF_INET;
685 packet->src_ipaddr.ipaddr.ip4addr.s_addr = htonl(INADDR_NONE);
686 packet->code = PW_CODE_ACCOUNTING_REQUEST;
687 gettimeofday(&packet->timestamp, NULL);
690 * Remember where it came from, so that we don't
691 * proxy it to the place it came from...
693 if (data->client_ip.af != AF_UNSPEC) {
694 packet->src_ipaddr = data->client_ip;
697 vp = pairfind(packet->vps, PW_PACKET_SRC_IP_ADDRESS, 0, TAG_ANY);
699 packet->src_ipaddr.af = AF_INET;
700 packet->src_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
702 vp = pairfind(packet->vps, PW_PACKET_SRC_IPV6_ADDRESS, 0, TAG_ANY);
704 packet->src_ipaddr.af = AF_INET6;
705 memcpy(&packet->src_ipaddr.ipaddr.ip6addr,
706 &vp->vp_ipv6addr, sizeof(vp->vp_ipv6addr));
710 vp = pairfind(packet->vps, PW_PACKET_DST_IP_ADDRESS, 0, TAG_ANY);
712 packet->dst_ipaddr.af = AF_INET;
713 packet->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
715 vp = pairfind(packet->vps, PW_PACKET_DST_IPV6_ADDRESS, 0, TAG_ANY);
717 packet->dst_ipaddr.af = AF_INET6;
718 memcpy(&packet->dst_ipaddr.ipaddr.ip6addr,
719 &vp->vp_ipv6addr, sizeof(vp->vp_ipv6addr));
724 * Generate packet ID, ports, IP via a counter.
726 packet->id = data->counter & 0xff;
727 packet->src_port = 1024 + ((data->counter >> 8) & 0xff);
728 packet->dst_port = 1024 + ((data->counter >> 16) & 0xff);
730 packet->dst_ipaddr.af = AF_INET;
731 packet->dst_ipaddr.ipaddr.ip4addr.s_addr = htonl((INADDR_LOOPBACK & ~0xffffff) | ((data->counter >> 24) & 0xff));
734 * If everything's OK, this is a waste of memory.
735 * Otherwise, it lets us re-send the original packet
736 * contents, unmolested.
738 packet->vps = paircopy(packet, data->vps);
741 * Prefer the Event-Timestamp in the packet, if it
742 * exists. That is when the event occurred, whereas the
743 * "Timestamp" field is when we wrote the packet to the
744 * detail file, which could have been much later.
746 vp = pairfind(packet->vps, PW_EVENT_TIMESTAMP, 0, TAG_ANY);
748 data->timestamp = vp->vp_integer;
752 * Look for Acct-Delay-Time, and update
753 * based on Acct-Delay-Time += (time(NULL) - timestamp)
755 vp = pairfind(packet->vps, PW_ACCT_DELAY_TIME, 0, TAG_ANY);
757 vp = paircreate(packet, PW_ACCT_DELAY_TIME, 0);
758 rad_assert(vp != NULL);
759 pairadd(&packet->vps, vp);
761 if (data->timestamp != 0) {
762 vp->vp_integer += time(NULL) - data->timestamp;
766 * Set the transmission count.
768 vp = pairfind(packet->vps, PW_PACKET_TRANSMIT_COUNTER, 0, TAG_ANY);
770 vp = paircreate(packet, PW_PACKET_TRANSMIT_COUNTER, 0);
771 rad_assert(vp != NULL);
772 pairadd(&packet->vps, vp);
774 vp->vp_integer = data->tries;
777 fr_printf_log("detail_recv: Read packet from %s\n", data->filename_work);
778 for (vp = fr_cursor_init(&cursor, &packet->vps);
780 vp = fr_cursor_next(&cursor)) {
785 data->state = STATE_RUNNING;
786 data->running = packet->timestamp.tv_sec;
792 * Free detail-specific stuff.
794 void detail_free(rad_listen_t *this)
796 listen_detail_t *data = this->data;
798 #ifdef WITH_DETAIL_THREAD
804 * Mark the child pipes as unusable
806 close(data->child_pipe[0]);
807 close(data->child_pipe[1]);
808 data->child_pipe[0] = -1;
811 * Tell it to stop (interrupting it's sleep)
813 pthread_kill(data->pthread_id, SIGTERM);
816 * Wait for it to acknowledge that it's stopped.
818 ret = read(data->master_pipe[0], &arg, sizeof(arg));
820 ERROR("Reader thread exited without informing the master: %s", fr_syserror(errno));
821 } else if (ret != sizeof(arg)) {
822 ERROR("Invalid thread pointer received from reader thread during exit");
823 ERROR("Expected %zu bytes, got %zi bytes", sizeof(arg), ret);
826 close(data->master_pipe[0]);
827 close(data->master_pipe[1]);
829 if (arg) pthread_join(data->pthread_id, &arg);
833 if (data->fp != NULL) {
840 int detail_print(rad_listen_t const *this, char *buffer, size_t bufsize)
843 return snprintf(buffer, bufsize, "%s",
844 ((listen_detail_t *)(this->data))->filename);
847 return snprintf(buffer, bufsize, "detail file %s as server %s",
848 ((listen_detail_t *)(this->data))->filename,
854 * Delay while waiting for a file to be ready
856 static int detail_delay(listen_detail_t *data)
858 int delay = (data->poll_interval - 1) * USEC;
861 * Add +/- 0.25s of jitter
863 delay += (USEC * 3) / 4;
864 delay += fr_rand() % (USEC / 2);
866 DEBUG2("Detail listener %s state %s waiting %d.%06d sec",
868 fr_int2str(state_names, data->state, "?"),
869 (delay / USEC), delay % USEC);
875 * Overloaded to return delay times.
877 int detail_encode(UNUSED rad_listen_t *this, UNUSED REQUEST *request)
879 #ifdef WITH_DETAIL_THREAD
882 listen_detail_t *data = this->data;
885 * We haven't sent a packet... delay things a bit.
887 if (!data->signal) return detail_delay(data);
891 DEBUG2("Detail listener %s state %s signalled %d waiting %d.%06d sec",
892 data->filename, fr_int2str(state_names, data->state, "?"),
894 data->delay_time / USEC,
895 data->delay_time % USEC);
897 return data->delay_time;
902 * Overloaded to return "should we fix delay times"
904 int detail_decode(UNUSED rad_listen_t *this, UNUSED REQUEST *request)
906 #ifdef WITH_DETAIL_THREAD
909 listen_detail_t *data = this->data;
916 #ifdef WITH_DETAIL_THREAD
917 static void *detail_handler_thread(void *arg)
920 rad_listen_t *this = arg;
921 listen_detail_t *data = this->data;
924 RADIUS_PACKET *packet;
926 while ((packet = detail_poll(this)) == NULL) {
927 usleep(detail_delay(data));
930 * If we're supposed to exit then tell
931 * the master thread we've exited.
933 if (data->child_pipe[0] < 0) {
935 if (write(data->master_pipe[1], &packet, sizeof(packet)) < 0) {
936 ERROR("Failed writing exit status to master: %s", fr_syserror(errno));
943 * Keep retrying forever.
945 * FIXME: cap the retries.
948 if (write(data->master_pipe[1], &packet, sizeof(packet)) < 0) {
949 ERROR("Failed passing detail packet pointer to master: %s", fr_syserror(errno));
952 if (read(data->child_pipe[0], &c, 1) < 0) {
953 ERROR("Failed getting detail packet ack from master: %s", fr_syserror(errno));
957 if (data->delay_time > 0) usleep(data->delay_time);
958 } while (data->state != STATE_REPLIED);
966 static const CONF_PARSER detail_config[] = {
967 { "detail", FR_CONF_OFFSET(PW_TYPE_FILE_OUTPUT | PW_TYPE_DEPRECATED, listen_detail_t, filename), NULL },
968 { "filename", FR_CONF_OFFSET(PW_TYPE_FILE_OUTPUT | PW_TYPE_REQUIRED, listen_detail_t, filename), NULL },
969 { "load_factor", FR_CONF_OFFSET(PW_TYPE_INTEGER, listen_detail_t, load_factor), STRINGIFY(10) },
970 { "poll_interval", FR_CONF_OFFSET(PW_TYPE_INTEGER, listen_detail_t, poll_interval), STRINGIFY(1) },
971 { "retry_interval", FR_CONF_OFFSET(PW_TYPE_INTEGER, listen_detail_t, retry_interval), STRINGIFY(30) },
972 { "one_shot", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, listen_detail_t, one_shot), NULL },
973 { "max_outstanding", FR_CONF_OFFSET(PW_TYPE_INTEGER, listen_detail_t, load_factor), NULL },
975 { NULL, -1, 0, NULL, NULL } /* end the list */
979 * Parse a detail section.
981 int detail_parse(CONF_SECTION *cs, rad_listen_t *this)
984 listen_detail_t *data;
990 rcode = cf_section_parse(cs, data, detail_config);
992 cf_log_err_cs(cs, "Failed parsing listen section");
997 * We don't do duplicate detection for "detail" sockets.
1000 this->synchronous = false;
1002 if (!data->filename) {
1003 cf_log_err_cs(cs, "No detail file specified in listen section");
1007 if ((data->load_factor < 1) || (data->load_factor > 100)) {
1008 cf_log_err_cs(cs, "Load factor must be between 1 and 100");
1012 if ((data->poll_interval < 1) || (data->poll_interval > 20)) {
1013 cf_log_err_cs(cs, "poll_interval must be between 1 and 20");
1017 if (check_config) return 0;
1019 if (data->max_outstanding == 0) data->max_outstanding = 1;
1022 * If the filename is a glob, use "detail.work" as the
1025 if ((strchr(data->filename, '*') != NULL) ||
1026 (strchr(data->filename, '[') != NULL)) {
1030 WARN("Detail file \"%s\" appears to use file globbing, but it is not supported on this system.",
1033 strlcpy(buffer, data->filename, sizeof(buffer));
1034 p = strrchr(buffer, FR_DIR_SEP);
1040 strlcat(buffer, "detail.work",
1041 sizeof(buffer) - strlen(buffer));
1044 snprintf(buffer, sizeof(buffer), "%s.work", data->filename);
1047 data->filename_work = talloc_strdup(data, buffer);
1052 data->state = STATE_UNOPENED;
1053 data->delay_time = data->poll_interval * USEC;
1057 * Initialize the fake client.
1059 client = &data->detail_client;
1060 memset(client, 0, sizeof(*client));
1061 client->ipaddr.af = AF_INET;
1062 client->ipaddr.ipaddr.ip4addr.s_addr = INADDR_NONE;
1063 client->ipaddr.prefix = 0;
1064 client->longname = client->shortname = data->filename;
1065 client->secret = client->shortname;
1066 client->nas_type = talloc_strdup(data, "none"); /* Part of 'data' not dynamically allocated */
1068 #ifdef WITH_DETAIL_THREAD
1070 * Create the communication pipes.
1072 if (pipe(data->master_pipe) < 0) {
1073 ERROR("radiusd: Error opening internal pipe: %s",
1074 fr_syserror(errno));
1078 if (pipe(data->child_pipe) < 0) {
1079 ERROR("radiusd: Error opening internal pipe: %s",
1080 fr_syserror(errno));
1084 pthread_create(&data->pthread_id, NULL, detail_handler_thread, this);
1086 this->fd = data->master_pipe[0];