# HG changeset patch
# User Bernd Schubert <[email protected]>
# Date 1289577717 -3600
# Node ID ad13ee71cc6672092b13a73e89c7b0894faa5146
# Parent  595b6919ab011ecc1229b479f729da4be95749b9
cl_log: Remove CircularBuffer

CircularBuffer was added more than 5 years ago and still it is not used.
So remove dead code, it can be retrieved from the repository history
if required.

Signed-off-by: Bernd Schubert <[email protected]>

diff --git a/include/clplumbing/cl_log.h b/include/clplumbing/cl_log.h
--- a/include/clplumbing/cl_log.h
+++ b/include/clplumbing/cl_log.h
@@ -63,31 +63,4 @@ void cl_log_args(int argc, char **argv);
 int cl_log_is_logd_fd(int fd);
 const char * prio2str(int priority);
 
-
-typedef struct CircularBuffer_s 
-{
-       const char*     name;
-       size_t          size;
-       gboolean        empty_after_dump;
-       GQueue*         queue;
-       
-} CircularBuffer_t;
-
-typedef struct CircularBufferEntry_s 
-{
-       int level;
-       char *buf;
-       
-} CircularBufferEntry_t;
-
-CircularBuffer_t *NewCircularBuffer(
-       const char *name, unsigned int size, gboolean empty_after_dump);
-void LogToCircularBuffer(
-       CircularBuffer_t *buffer, int level, const char *fmt, ...) 
G_GNUC_PRINTF(3,4);
-
-void EmptyCircularBuffer(CircularBuffer_t *buffer);
-
-/* the prototype is designed to be easy to give to G_main_add_SignalHandler() 
*/
-gboolean DumpCircularBuffer(int nsig, gpointer buffer);
-
 #endif
diff --git a/lib/clplumbing/cl_log.c b/lib/clplumbing/cl_log.c
--- a/lib/clplumbing/cl_log.c
+++ b/lib/clplumbing/cl_log.c
@@ -1017,120 +1017,6 @@ cl_opensyslog(void)
        openlog(common_log_entity, LOG_CONS, cl_log_facility);
 }
 
-/* What a horrible substitute for a low-overhead event log!! - FIXME!! */
-
-CircularBuffer_t *
-NewCircularBuffer(const char *name, uint size, gboolean empty_after_dump)
-{
-       CircularBuffer_t *buffer = malloc(sizeof(CircularBuffer_t));
-       if (!buffer) {
-               return buffer;
-       }
-       buffer->name = name;
-       buffer->size = size;
-       buffer->empty_after_dump = empty_after_dump;
-       buffer->queue = g_queue_new();
-
-#if 1
-       if(empty_after_dump == FALSE) {
-               cl_log(LOG_ERR, "This requires glib 2.4");
-               empty_after_dump = TRUE;
-       }
-#endif
-
-       return buffer;
-}
-
-void
-LogToCircularBuffer(CircularBuffer_t *buffer, int level, const char *fmt, ...)
-{
-       va_list ap;
-       char buf[MAXLINE];
-       int     nbytes;
-       CircularBufferEntry_t *entry = malloc(sizeof(CircularBufferEntry_t));
-       
-       if (!entry) {
-               return;
-       }
-       va_start(ap, fmt);
-       nbytes=vsnprintf(buf, MAXLINE, fmt, ap);
-       /*      nbytes=vasprintf(&buf, fmt, ap); */
-       va_end(ap);
-
-       entry->buf = buf;
-       entry->level = level;
-
-       g_queue_push_tail(buffer->queue, entry);
-
-       while(buffer->queue->length > buffer->size) {
-               entry = g_queue_pop_head(buffer->queue);
-               free(entry->buf);
-               free(entry);
-       }
-}
-
-void
-EmptyCircularBuffer(CircularBuffer_t *buffer) 
-{
-       CircularBufferEntry_t *entry = NULL;
-       while(buffer->queue->length > 0) {
-               entry = g_queue_pop_head(buffer->queue);
-               free(entry->buf);
-               free(entry);
-       }
-}
-
-gboolean
-DumpCircularBuffer(int nsig, gpointer user_data) 
-{
-       CircularBuffer_t *buffer = user_data;
-       CircularBufferEntry_t *entry = NULL;
-       
-       if(buffer == NULL) {
-               /* error */
-               cl_log(LOG_ERR, "No buffer supplied to dump.");
-               return FALSE;
-       }
-
-       if(logging_daemon_chan != NULL
-          && logging_daemon_chan->send_queue->max_qlen < buffer->size) {
-               /* We have no hope of getting the whole buffer out via the
-                *  logging daemon.  Use direct log instead so the messages
-                *  come out in the right order.
-                */ 
-               cl_log_depth++;
-       }
-       
-       cl_log(LOG_INFO, "Mark: Begin dump of buffer %s", buffer->name);
-       if(buffer->empty_after_dump) {
-               while(buffer->queue->length > 0) {
-                       entry = g_queue_pop_head(buffer->queue);
-                       cl_log(entry->level, "%s", entry->buf);
-                       free(entry->buf);
-                       free(entry);
-               }
-
-       } else {
-#if 1
-               cl_log(LOG_ERR, "This requires g_queue_peek_nth() from glib 
2.4");
-#else
-               uint lpc = 0;
-               uint queue_len = buffer->queue->length;
-               for(lpc = 0; lpc < queue_len; lpc++) {
-                       entry = g_queue_peek_nth(buffer->queue, lpc);
-                       cl_log(entry->level, "%s", entry->buf);
-               }
-#endif
-       }
-       if(logging_daemon_chan != NULL
-          && logging_daemon_chan->send_queue->max_qlen < buffer->size) {
-               /* Return is back to normal */
-               cl_log_depth--;
-       }
-       cl_log(LOG_INFO, "Mark: End dump of buffer %s", buffer->name);
-       return TRUE;
-}
-
 
 void
 cl_log_args(int argc, char **argv)
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to