PATCH: allow detail listeners to write to other files
I noticed[1] that detail listeners refuse to write detail entries to files, even if the destination filename is different from the source filename. The attached patch fixes that. It also centralizes the listen_detail_t definition, removing the 'stub' definition in src/main/event.c. john [1] https://lists.freeradius.org/pipermail/freeradius-users/2009-October/msg0018... -- John Morrissey _o /\ ---- __o jwm@horde.net _-< \_ / \ ---- < \, www.horde.net/ __(_)/_(_)________/ \_______(_) /_(_)__
On Thu, Oct 08, 2009 at 12:52:37PM -0400, John Morrissey wrote:
I noticed[1] that detail listeners refuse to write detail entries to files, even if the destination filename is different from the source filename.
The attached patch fixes that. It also centralizes the listen_detail_t definition, removing the 'stub' definition in src/main/event.c.
I've updated this patch to apply after aafb547572e28f14cbe27d84f2346b93a07265f5. john diff --git a/src/include/detail.h b/src/include/detail.h index 699b1be..4c164d7 100644 --- a/src/include/detail.h +++ b/src/include/detail.h @@ -10,6 +10,40 @@ #include <freeradius-devel/ident.h> RCSIDH(detail_h, "$Id$") +typedef enum detail_state_t { + STATE_UNOPENED = 0, + STATE_UNLOCKED, + STATE_HEADER, + STATE_READING, + STATE_QUEUED, + STATE_RUNNING, + STATE_NO_REPLY, + STATE_REPLIED +} detail_state_t; + +typedef struct listen_detail_t { + fr_event_t *ev; /* has to be first entry (ugh) */ + int delay_time; + char *filename; + char *filename_work; + VALUE_PAIR *vps; + FILE *fp; + detail_state_t state; + time_t timestamp; + time_t running; + fr_ipaddr_t client_ip; + int load_factor; /* 1..100 */ + int signal; + int poll_interval; + int retry_interval; + + int has_rtt; + int srtt; + int rttvar; + struct timeval last_packet; + RADCLIENT detail_client; +} listen_detail_t; + int detail_recv(rad_listen_t *listener, RAD_REQUEST_FUNP *pfun, REQUEST **prequest); int detail_send(rad_listen_t *listener, REQUEST *request); diff --git a/src/main/detail.c b/src/main/detail.c index 89804cd..6e8e2db 100644 --- a/src/main/detail.c +++ b/src/main/detail.c @@ -43,17 +43,6 @@ RCSID("$Id$") #define USEC (1000000) -typedef enum detail_state_t { - STATE_UNOPENED = 0, - STATE_UNLOCKED, - STATE_HEADER, - STATE_READING, - STATE_QUEUED, - STATE_RUNNING, - STATE_NO_REPLY, - STATE_REPLIED -} detail_state_t; - static FR_NAME_NUMBER state_names[] = { { "unopened", STATE_UNOPENED }, { "unlocked", STATE_UNLOCKED }, @@ -67,29 +56,6 @@ static FR_NAME_NUMBER state_names[] = { { NULL, 0 } }; -typedef struct listen_detail_t { - fr_event_t *ev; /* has to be first entry (ugh) */ - int delay_time; - char *filename; - char *filename_work; - VALUE_PAIR *vps; - FILE *fp; - detail_state_t state; - time_t timestamp; - time_t running; - fr_ipaddr_t client_ip; - int load_factor; /* 1..100 */ - int signal; - int poll_interval; - int retry_interval; - - int has_rtt; - int srtt; - int rttvar; - struct timeval last_packet; - RADCLIENT detail_client; -} listen_detail_t; - /* * If we're limiting outstanding packets, then mark the response diff --git a/src/main/event.c b/src/main/event.c index 51e6c9c..ad2ca32 100644 --- a/src/main/event.c +++ b/src/main/event.c @@ -3797,10 +3797,6 @@ static void event_socket_handler(fr_event_list_t *xel, UNUSED int fd, } } -typedef struct listen_detail_t { - fr_event_t *ev; -} listen_detail_t; - /* * This function is called periodically to see if this detail * file is available for reading. diff --git a/src/modules/rlm_detail/rlm_detail.c b/src/modules/rlm_detail/rlm_detail.c index 56681fb..fba5e9d 100644 --- a/src/modules/rlm_detail/rlm_detail.c +++ b/src/modules/rlm_detail/rlm_detail.c @@ -26,6 +26,7 @@ RCSID("$Id$") #include <freeradius-devel/radiusd.h> #include <freeradius-devel/modules.h> #include <freeradius-devel/rad_assert.h> +#include <freeradius-devel/detail.h> #include <sys/stat.h> #include <ctype.h> @@ -475,7 +476,9 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet, */ static int detail_accounting(void *instance, REQUEST *request) { - if (request->listener->type == RAD_LISTEN_DETAIL) { + if (request->listener->type == RAD_LISTEN_DETAIL && + strcmp(((struct detail_instance *)instance)->detailfile, + ((listen_detail_t *)request->listener->data)->filename) == 0) { RDEBUG("Suppressing writes to detail file as the request was just read from a detail file."); return RLM_MODULE_NOOP; } -- John Morrissey _o /\ ---- __o jwm@horde.net _-< \_ / \ ---- < \, www.horde.net/ __(_)/_(_)________/ \_______(_) /_(_)__
On Wed, Oct 21, 2009 at 04:01:09PM -0400, John Morrissey wrote:
On Thu, Oct 08, 2009 at 12:52:37PM -0400, John Morrissey wrote:
I noticed[1] that detail listeners refuse to write detail entries to files, even if the destination filename is different from the source filename.
The attached patch fixes that. It also centralizes the listen_detail_t definition, removing the 'stub' definition in src/main/event.c.
I've updated this patch to apply after aafb547572e28f14cbe27d84f2346b93a07265f5.
Any word on this, Alan? john
diff --git a/src/include/detail.h b/src/include/detail.h index 699b1be..4c164d7 100644 --- a/src/include/detail.h +++ b/src/include/detail.h @@ -10,6 +10,40 @@ #include <freeradius-devel/ident.h> RCSIDH(detail_h, "$Id$")
+typedef enum detail_state_t { + STATE_UNOPENED = 0, + STATE_UNLOCKED, + STATE_HEADER, + STATE_READING, + STATE_QUEUED, + STATE_RUNNING, + STATE_NO_REPLY, + STATE_REPLIED +} detail_state_t; + +typedef struct listen_detail_t { + fr_event_t *ev; /* has to be first entry (ugh) */ + int delay_time; + char *filename; + char *filename_work; + VALUE_PAIR *vps; + FILE *fp; + detail_state_t state; + time_t timestamp; + time_t running; + fr_ipaddr_t client_ip; + int load_factor; /* 1..100 */ + int signal; + int poll_interval; + int retry_interval; + + int has_rtt; + int srtt; + int rttvar; + struct timeval last_packet; + RADCLIENT detail_client; +} listen_detail_t; + int detail_recv(rad_listen_t *listener, RAD_REQUEST_FUNP *pfun, REQUEST **prequest); int detail_send(rad_listen_t *listener, REQUEST *request); diff --git a/src/main/detail.c b/src/main/detail.c index 89804cd..6e8e2db 100644 --- a/src/main/detail.c +++ b/src/main/detail.c @@ -43,17 +43,6 @@ RCSID("$Id$")
#define USEC (1000000)
-typedef enum detail_state_t { - STATE_UNOPENED = 0, - STATE_UNLOCKED, - STATE_HEADER, - STATE_READING, - STATE_QUEUED, - STATE_RUNNING, - STATE_NO_REPLY, - STATE_REPLIED -} detail_state_t; - static FR_NAME_NUMBER state_names[] = { { "unopened", STATE_UNOPENED }, { "unlocked", STATE_UNLOCKED }, @@ -67,29 +56,6 @@ static FR_NAME_NUMBER state_names[] = { { NULL, 0 } };
-typedef struct listen_detail_t { - fr_event_t *ev; /* has to be first entry (ugh) */ - int delay_time; - char *filename; - char *filename_work; - VALUE_PAIR *vps; - FILE *fp; - detail_state_t state; - time_t timestamp; - time_t running; - fr_ipaddr_t client_ip; - int load_factor; /* 1..100 */ - int signal; - int poll_interval; - int retry_interval; - - int has_rtt; - int srtt; - int rttvar; - struct timeval last_packet; - RADCLIENT detail_client; -} listen_detail_t; -
/* * If we're limiting outstanding packets, then mark the response diff --git a/src/main/event.c b/src/main/event.c index 51e6c9c..ad2ca32 100644 --- a/src/main/event.c +++ b/src/main/event.c @@ -3797,10 +3797,6 @@ static void event_socket_handler(fr_event_list_t *xel, UNUSED int fd, } }
-typedef struct listen_detail_t { - fr_event_t *ev; -} listen_detail_t; - /* * This function is called periodically to see if this detail * file is available for reading. diff --git a/src/modules/rlm_detail/rlm_detail.c b/src/modules/rlm_detail/rlm_detail.c index 56681fb..fba5e9d 100644 --- a/src/modules/rlm_detail/rlm_detail.c +++ b/src/modules/rlm_detail/rlm_detail.c @@ -26,6 +26,7 @@ RCSID("$Id$") #include <freeradius-devel/radiusd.h> #include <freeradius-devel/modules.h> #include <freeradius-devel/rad_assert.h> +#include <freeradius-devel/detail.h>
#include <sys/stat.h> #include <ctype.h> @@ -475,7 +476,9 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet, */ static int detail_accounting(void *instance, REQUEST *request) { - if (request->listener->type == RAD_LISTEN_DETAIL) { + if (request->listener->type == RAD_LISTEN_DETAIL && + strcmp(((struct detail_instance *)instance)->detailfile, + ((listen_detail_t *)request->listener->data)->filename) == 0) { RDEBUG("Suppressing writes to detail file as the request was just read from a detail file."); return RLM_MODULE_NOOP; }
-- John Morrissey _o /\ ---- __o jwm@horde.net _-< \_ / \ ---- < \, www.horde.net/ __(_)/_(_)________/ \_______(_) /_(_)__
John Morrissey wrote:
The attached patch fixes that. It also centralizes the listen_detail_t definition, removing the 'stub' definition in src/main/event.c. I've updated this patch to apply after aafb547572e28f14cbe27d84f2346b93a07265f5.
Any word on this, Alan?
Could you put the patch into your git repository? Ideally, also please put *all* of your patches into a branch. Using the "master" branch for your local patches makes integration difficult. If you put all of your patches into a private branch, you can easily keep up to date via: $ git checkout -b jwm $ git fetch freeradius master:master $ git merge master The branch will contain *only* the local patches. This makes it easier to do inter-branch diffs, etc. Alan DeKok.
On Sun, Nov 22, 2009 at 09:24:10AM +0100, Alan DeKok wrote:
John Morrissey wrote:
The attached patch fixes that. It also centralizes the listen_detail_t definition, removing the 'stub' definition in src/main/event.c. I've updated this patch to apply after aafb547572e28f14cbe27d84f2346b93a07265f5.
Any word on this, Alan?
Could you put the patch into your git repository?
Ideally, also please put *all* of your patches into a branch. Using the "master" branch for your local patches makes integration difficult.
Done, and done. john -- John Morrissey _o /\ ---- __o jwm@horde.net _-< \_ / \ ---- < \, www.horde.net/ __(_)/_(_)________/ \_______(_) /_(_)__
John Morrissey wrote:
Ideally, also please put *all* of your patches into a branch. Using the "master" branch for your local patches makes integration difficult.
Done, and done.
Applied, thanks. Also, most development is done on the "stable" branch. The "master" branch has a number of other changes that might not ever make it into a release. Alan DeKok.
participants (2)
-
Alan DeKok -
John Morrissey