]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clean up logic and note "todo"
authorAlan T. DeKok <aland@freeradius.org>
Tue, 26 Sep 2017 19:57:20 +0000 (15:57 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 27 Sep 2017 16:25:24 +0000 (12:25 -0400)
src/modules/proto_detail/proto_detail_file.c

index 25fe910755fc8f50d7e41aba00a29aa4e184b1d2..590496203e139b24384c968ac6210f570d6a701c 100644 (file)
 #include <fcntl.h>
 #include <sys/stat.h>
 
+#if 0
+/*
+ *     When we want detailed debugging here, without detailed server
+ *     debugging.
+ */
 #define MPRINT DEBUG
+#else
+#define MPRINT DEBUG3
+#endif
 
 typedef struct {
        fr_time_t                       timestamp;              //!< when we read the entry.
@@ -164,24 +172,21 @@ static ssize_t mod_read(void *instance, void **packet_ctx, fr_time_t **recv_time
        }
 
 redo:
-       /*
-        *      Look for "end of record" marker.  We've already
-        *      searched "leftover" bytes for \n\n, so we only have to
-        *      search the remaining bytes.
-        *
-        *      We MIGHT have the last character of the previously
-        *      read data as \n, so we back up one character here.
-        *      That lets us catch "\n\n" which crosses a read()
-        *      boundary.
-        */
-       if (*leftover > 0) partial--;
+       next = NULL;
 
        /*
+        *      Look for "end of record" marker, starting from the
+        *      beginning of the buffer.
+        *
+        *      @todo - remember in 'inst' how far we searched, so we
+        *      don't need to do that again.  Also, if the last
+        *      character of the search is \n, stop the search there,
+        *      instead of going to the next character.
+        *
         *      Note that all of the data MUST be printable, and raw
         *      LFs are forbidden in attribute contents.
         */
-       next = NULL;
-       for (p = partial; p < end; p++) {
+       for (p = buffer; p < end; p++) {
                if (p[0] != '\n') continue;
                if ((p + 1) == end) break; /* no more data */
                if (p[1] == '\n') {