innfeed busy logging timer stats
Florian Schlichting
fschlich at CIS.FU-Berlin.DE
Thu Jun 23 18:30:53 UTC 2011
Russ, thank you for your explanations. My patch is below.
On Wed, Jun 22, 2011 at 03:24:53PM -0700, Russ Allbery wrote:
> Florian Schlichting <fschlich at CIS.FU-Berlin.DE> writes:
> > void lineIsRead (EndPoint myEp, IoStatus status, Buffer *buffer, void *data);
> > void lineIsRead (EndPoint myEp, IoStatus status, Buffer *buffer, void *d)
> > {
> > Buffer *writeBuffers, *readBuffers ;
> > Buffer newBuff1, newBuff2 ;
> > Buffer newInputBuffer ;
> > char *data, *p ;
> > ...
>
> > 3) Would it be ok to rename "Buffer *buffer" to "Buffer *buffers" in the
> > above code, and "*d" to "*unused"? Preferable?
>
> buffers seems better. For the data pointer, I assume this function is
> used as a callback. In that case, the variable names should generally
> match in all the callback functions with the same prototype, just for aid
> in reading the code. (But if it's not used, it should be marked with
> UNUSED.)
yes, it's a callback, defined in misc.h as
typedef void (*EndpRWCB) (EndPoint e, IoStatus i, Buffer b, void *d);
connection.c and imap_connection.c seem to stick to these variable names
fairly strictly, whereas endpoint.c and innlistener.c do not. I think
it's better to use longer and more telling names, so I didn't touch the
latter except for *d in endpoint.c, which is never used.
Oh well, there's no consistency without touching half the lines, but I
think it gets a little clearer here and there...
Florian
---
innfeed/endpoint.c | 52 +++++++++++++++++++++++-----------------------------
innfeed/endpoint.h | 18 +++++++++---------
2 files changed, 32 insertions(+), 38 deletions(-)
diff --git a/innfeed/endpoint.c b/innfeed/endpoint.c
index 0ce1d69..196f299 100644
--- a/innfeed/endpoint.c
+++ b/innfeed/endpoint.c
@@ -348,19 +348,19 @@ int endPointFd (EndPoint endp)
-/* Request a read to be done next time there's data. The endpoint
- * ENDP is what will do the read. BUFF is the Buffer the data should
- * go into. FUNC is the callback function to call when the read is
- * complete. CLIENTDATA is the client data to pass back into the
+/* Request a read to be done next time there's data. The endpoint ENDP
+ * is what will do the read. BUFFERS is the array of Buffers the data
+ * should go into. FUNC is the callback function to call when the read
+ * is complete. CLIENTDATA is the client data to pass back into the
* callback function. MINLEN is the minimum amount of data to
- * read. If MINLEN is 0 then then BUFF must be filled, otherwise at
+ * read. If MINLEN is 0 then then BUFFERS must be filled, otherwise at
* least MINLEN bytes must be read.
*
- * BUFF can be null, in which case no read is actually done, but the
+ * BUFFERS can be NULL, in which case no read is actually done, but the
* callback function will be called still. This is useful for
* listening sockets.
*
- * Returns 0 if the read couln't be prepared (for example if a read
+ * Returns 0 if the read couldn't be prepared (for example if a read
* is already outstanding).
*/
@@ -403,12 +403,12 @@ int prepareRead (EndPoint endp,
-/* Request a write to be done at a later point. ENDP is the EndPoint
- * to do the write. BUFF is the Buffer to write from. FUNC is the
- * function to call when the write is complete. CLIENTDATA is some
+/* Request a write to be done at a later point. ENDP is the EndPoint to
+ * do the write. BUFFERS is the array of Buffers to write from. FUNC is
+ * the function to call when the write is complete. CLIENTDATA is some
* data to hand back to the callback function.
*
- * If BUFF is null, then no write will actually by done, but the
+ * If BUFFERS is NULL, then no write will actually by done, but the
* callback function will still be called. This is useful for
* connecting sockets.
*
@@ -530,7 +530,7 @@ TimeoutId prepareSleep (EndpTCB func, int timeToSleep, void *clientData)
}
-/* Updates a an existing timeout request to go off TIMETOSLEEP seconds from
+/* Updates an existing timeout request to go off TIMETOSLEEP seconds from
now, or queues a new request. Always returns a new ID. */
TimeoutId updateSleep (TimeoutId tid, EndpTCB func, int timeToSleep,
void *clientData)
@@ -1392,15 +1392,13 @@ static void doTimeout (void)
#define BUFF_SIZE 100
-void timerCallback (void *cd) ;
-void timerCallback (void *cd)
+static void timerCallback (void *cd)
{
d_printf (1,"Callback \n") ;
}
-void lineIsWritten (EndPoint ep, IoStatus status, Buffer *buffer, void *data);
-void lineIsWritten (EndPoint ep, IoStatus status, Buffer *buffer, void *data)
+static void lineIsWritten (EndPoint ep, IoStatus status, Buffer *buffers, void *d UNUSED)
{
int i ;
@@ -1415,12 +1413,11 @@ void lineIsWritten (EndPoint ep, IoStatus status, Buffer *buffer, void *data)
errno = oldErrno ;
}
- for (i = 0 ; buffer && buffer [i] ; i++)
- delBuffer (buffer [i]) ;
+ for (i = 0 ; buffers && buffers[i] ; i++)
+ delBuffer (buffers[i]);
}
-void lineIsRead (EndPoint myEp, IoStatus status, Buffer *buffer, void *data);
-void lineIsRead (EndPoint myEp, IoStatus status, Buffer *buffer, void *d)
+void lineIsRead (EndPoint myEp, IoStatus status, Buffer *buffers, void *d UNUSED)
{
Buffer *writeBuffers, *readBuffers ;
Buffer newBuff1, newBuff2 ;
@@ -1447,13 +1444,13 @@ void lineIsRead (EndPoint myEp, IoStatus status, Buffer *buffer, void *d)
}
- data = bufferBase (buffer[0]) ;
- len = bufferDataSize (buffer[0]) ;
+ data = bufferBase (buffers[0]);
+ len = bufferDataSize (buffers[0]);
if (data [len - 1] == '\r' || data [len - 1] == '\n')
- bufferDecrDataSize (buffer [0],1) ;
+ bufferDecrDataSize (buffers[0], 1);
if (data [len - 1] == '\r' || data [len - 1] == '\n')
- bufferDecrDataSize (buffer [0],1) ;
+ bufferDecrDataSize (buffers[0], 1);
data [len] = '\0' ;
@@ -1471,7 +1468,7 @@ void lineIsRead (EndPoint myEp, IoStatus status, Buffer *buffer, void *d)
strlcpy (p,"\" very tasty\n", bufferSize (newBuff2)) ;
bufferSetDataSize (newBuff2,strlen (p)) ;
- writeBuffers = makeBufferArray (newBuff1,buffer[0],newBuff2,NULL) ;
+ writeBuffers = makeBufferArray (newBuff1, buffers[0], newBuff2, NULL);
readBuffers = makeBufferArray (newInputBuffer,NULL) ;
prepareWrite (myEp,writeBuffers,lineIsWritten,NULL) ;
@@ -1483,7 +1480,6 @@ void lineIsRead (EndPoint myEp, IoStatus status, Buffer *buffer, void *d)
}
-static void printDate (TimeoutId tid, void *data) ;
static void printDate (TimeoutId tid, void *data)
{
char dateString[30];
@@ -1503,7 +1499,6 @@ static void printDate (TimeoutId tid, void *data)
TimeoutId rm ;
-static void Timeout (TimeoutId tid, void *data) ;
static void Timeout (TimeoutId tid, void *data)
{
static int seeded ;
@@ -1543,8 +1538,7 @@ static void Timeout (TimeoutId tid, void *data)
}
-void newConn (EndPoint ep, IoStatus status, Buffer *buffer, void *d) ;
-void newConn (EndPoint ep, IoStatus status, Buffer *buffer, void *d)
+static void newConn (EndPoint ep, IoStatus status, Buffer *buffers UNUSED, void *d UNUSED)
{
EndPoint newEp ;
struct sockaddr_in in ;
diff --git a/innfeed/endpoint.h b/innfeed/endpoint.h
index 2985332..4cfa338 100644
--- a/innfeed/endpoint.h
+++ b/innfeed/endpoint.h
@@ -74,14 +74,14 @@
EndPoint newEndPoint (int fd) ;
/* shutdown the file descriptor and delete the endpoint. */
-void delEndPoint (EndPoint endp) ;
+void delEndPoint (EndPoint ep);
/* return the file descriptor the endpoint is managing */
int endPointFd (EndPoint endp) ;
/* Request a read when available. Reads MINLEN bytes into the
- * buffers in BUFFS. BUFFS is an array of Buffers, the last of which
- * must be NULL. Note that ownership of BUFFS is never asserted, but
+ * buffers in BUFFERS. BUFFERS is an array of Buffers, the last of which
+ * must be NULL. Note that ownership of BUFFERS is never asserted, but
* the ownership of the Buffers in it is. So if an EndPoint is
* deleted while a read is pending the Buffers will be released, but
* the array won't be. If MINLEN is 0 then the buffers must be
@@ -90,15 +90,15 @@ int endPointFd (EndPoint endp) ;
* callback. Returns non-zero if can be scheduled for processing.
*/
int prepareRead (EndPoint endp,
- Buffer *buffs,
+ Buffer *buffers,
EndpRWCB func,
void *clientData,
int minlen) ;
/* Request a write when possible. All the data in the buffers in
- * BUFFS will be written out the endpoint. BUFFS is a NULL
- * terminated array of Buffers. See prepareWrite for a discussion on
- * the ownership of BUFFS and the Buffers inside BUFFS. The PROGRESS
+ * BUFFERS will be written out the endpoint. BUFFERS is a NULL
+ * terminated array of Buffers. See prepareRead for a discussion on
+ * the ownership of BUFFERS and the Buffers inside BUFFERS. The PROGRESS
* callback function will be called and the CLIENTDATA value will be
* passed through to it whenever any data is written except for the
* final write. The DONE callback function will be called and the
@@ -106,7 +106,7 @@ int prepareRead (EndPoint endp,
* Returns non-zero if scheduled succesfully.
*/
int prepareWrite (EndPoint endp,
- Buffer *buffs,
+ Buffer *buffers,
EndpRWCB progress,
EndpRWCB done,
void *clientData) ;
@@ -144,7 +144,7 @@ TimeoutId updateSleep (TimeoutId tid,
been serviced. */
void *addWorkCallback (EndPoint endp, EndpWorkCbk cbk, void *data) ;
-void setSigHandler (int sig, void (*)(int)) ;
+void setSigHandler (int signum, void (*ptr)(int));
/* remove the timeout that was previously requested. Retuesn true if
succesfully removed, false otherwise. 0 is a legal parameter value, in
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5557 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/inn-workers/attachments/20110623/70e01416/attachment.bin>
More information about the inn-workers
mailing list