Skip to content

Commit dc1ff66

Browse files
author
Michael Ortmann
committed
EXPERIMENTAL WORKAROUND: START OF MODE QUEUE DEQUEUING DELAYED + merge of eggheads#1441 and eggheads#1087 for better logging during debug session
1 parent 8efbe7a commit dc1ff66

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

eggdrop.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ logfile mco * "logs/eggdrop.log"
187187
set log-time 1
188188

189189
# Set the following to the timestamp for the logfile entries. Popular times
190-
# might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec).
191-
# Read `man strftime' for more formatting options. Keep it below 32 chars.
190+
# might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec). Read
191+
# 'man strftime' for more formatting options. Additionally eggdrop supports %f
192+
# for milliseconds. Keep it below 32 chars.
192193
set timestamp-format {[%H:%M:%S]}
193194

194195
# If you want to keep your logfiles forever, turn this setting on. All
@@ -1515,7 +1516,7 @@ set xfer-timeout 30
15151516
#loadmodule compress
15161517

15171518
# Allow compressed sending of user files? The user files are compressed with
1518-
# the compression level defined in `compress-level'.
1519+
# the compression level defined in 'compress-level'.
15191520
set share-compressed 1
15201521

15211522
# This is the default compression level used. These levels are the same as

src/misc.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,13 @@ void putlog (int type, char *chname, const char *format, ...)
514514
{
515515
static int inhere = 0;
516516
int i, tsl = 0;
517-
char s[LOGLINELEN], path[PATH_MAX], *out, ct[81], *s2, stamp[34];
517+
char s[LOGLINELEN], path[PATH_MAX], *out, ct[81], *s2, stamp[34],
518+
stamp2[sizeof stamp], *f, c;
518519
va_list va;
519520
time_t now2 = time(NULL);
520521
static time_t now2_last = 0; /* cache expensive localtime() */
521522
static struct tm t;
523+
struct timeval tv;
522524

523525
if (now2 != now2_last) {
524526
now2_last = now2;
@@ -529,12 +531,25 @@ void putlog (int type, char *chname, const char *format, ...)
529531

530532
/* Create the timestamp */
531533
if (shtime) {
532-
strftime(stamp, sizeof(stamp) - 2, log_ts, &t);
533-
strcat(stamp, " ");
534-
tsl = strlen(stamp);
534+
strlcpy(stamp, log_ts, sizeof stamp);
535+
536+
/* handle millisecond specifier %f */
537+
if ((f = strstr(stamp, "%f")) && ((f - 1) != (strstr(stamp, "%%f")))) {
538+
memmove(f + 3, f + 2, strlen(f + 2) + 1);
539+
c = f[3]; /* save the char the following snprintf() will overwrite with
540+
* null terminator
541+
*/
542+
gettimeofday(&tv, NULL);
543+
snprintf(f, sizeof stamp - (f - stamp), "%03i", (int) tv.tv_usec / 1000);
544+
f[3] = c;
545+
}
546+
547+
strftime(stamp2, sizeof(stamp2) - 2, stamp, &t);
548+
strcat(stamp2, " ");
549+
tsl = strlen(stamp2);
535550
}
536551
else
537-
*stamp = '\0';
552+
*stamp2 = '\0';
538553

539554
/* Format log entry at offset 'tsl,' then i can prepend the timestamp */
540555
out = s + tsl;
@@ -566,7 +581,7 @@ void putlog (int type, char *chname, const char *format, ...)
566581
}
567582
/* Place the timestamp in the string to be printed */
568583
if (out[0] && shtime) {
569-
memcpy(s, stamp, tsl);
584+
memcpy(s, stamp2, tsl);
570585
out = s;
571586
}
572587
strcat(out, "\n");
@@ -599,7 +614,7 @@ void putlog (int type, char *chname, const char *format, ...)
599614
* then reset repeats. We want the current time here,
600615
* so put that in the file first.
601616
*/
602-
fprintf(logs[i].f, "%s", stamp);
617+
fprintf(logs[i].f, "%s", stamp2);
603618
fprintf(logs[i].f, MISC_LOGREPEAT, logs[i].repeats);
604619
logs[i].repeats = 0;
605620
/* No need to reset logs[i].szlast here

src/mod/server.mod/server.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ static void deq_msg()
206206

207207
/* Send up to 4 msgs to server if the *critical queue* has anything in it */
208208
if (modeq.head) {
209+
if (trying_server) {
210+
putlog(LOG_MISC, "*", "EXPERIMENTAL WORKAROUND: START OF MODE QUEUE DEQUEUING DELAYED");
211+
return;
212+
}
213+
209214
while (modeq.head && (burst < 4) && ((last_time - now) < MAXPENALTY)) {
210215
if (deq_kick(DP_MODE)) {
211216
burst++;

src/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828

2929
#define EGG_STRINGVER "1.9.5"
3030
#define EGG_NUMVER 1090504
31-
#define EGG_PATCH "needtls"
31+
#define EGG_PATCH "experimental"

0 commit comments

Comments
 (0)