r28321 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r28320‎ | r28321 | r28322 >
Date:17:31, 9 December 2007
Author:midom
Status:old
Tags:
Comment:
minor fixes, add serial number to format
Modified paths:
  • /trunk/webstatscollector/collector.c (modified) (history)
  • /trunk/webstatscollector/export.c (modified) (history)

Diff [purge]

Index: trunk/webstatscollector/export.c
@@ -28,10 +28,6 @@
2929 bzero(&key,sizeof(key));
3030 bzero(&data,sizeof(data));
3131
32 - if (db==NULL) {
33 - db_create(&db,NULL,0);
34 - db->open(db,NULL,"stats.db",NULL,DB_BTREE,0,0);
35 - }
3632 db->cursor(db,NULL,&c,0);
3733 while(c->c_get(c, &key, &data, DB_NEXT )==0) {
3834 entry=data.data;
@@ -44,7 +40,7 @@
4541
4642 /* Get EVENT */
4743 fprintf(fd,"%s %s %llu %llu\n",
48 - project,(page==NULL?page:"-"),
 44+ project,(page?page:"-"),
4945 entry->wc_count, entry->wc_bytes);
5046 }
5147 c->c_close(c);
Index: trunk/webstatscollector/collector.c
@@ -128,9 +128,11 @@
129129 char keytext[1200];
130130 int r;
131131
 132+ unsigned long long serial;
 133+
132134 struct wcstats incoming;
133135 /* project count bytesize page */
134 - const char msgformat[]="%127s %llu %llu %1023[^\n]";
 136+ const char msgformat[]="%llu %127s %llu %llu %1023[^\n]";
135137
136138 buf[l]=0;
137139 pp=buf;
@@ -143,11 +145,11 @@
144146 return;
145147 }
146148 bzero(&incoming,sizeof(incoming));
147 - r=sscanf(p,msgformat,(char *)&project,
 149+ r=sscanf(p,msgformat,&serial,(char *)&project,
148150 &incoming.wc_count,
149151 &incoming.wc_bytes,
150152 (char *)&title);
151 - if (r<4)
 153+ if (r<5)
152154 continue;
153155 snprintf(keytext,1499,"%s:%s",project,title);
154156
@@ -170,10 +172,10 @@
171173 void increaseStatistics(DB *db, char *keytext, struct wcstats *incoming ) {
172174 struct wcstats *old;
173175 DBT key,data;
174 -
 176+
175177 bzero(&key,sizeof(key));
176178 key.data=keytext;
177 - key.size=strlen(keytext);
 179+ key.size=strlen(keytext)+1;
178180
179181 bzero(&data,sizeof(data));
180182
@@ -227,7 +229,7 @@
228230 pthread_t dumper,aggrdumper;
229231 static struct dumperjob dumperJob, aggrDumperJob;
230232 DB *olddb,*oldaggr;
231 - time_t dumptime;
 233+ time_t dumptime=0;
232234
233235 time(&dumptime);
234236
@@ -249,7 +251,8 @@
250252
251253 pthread_create(&aggrdumper,NULL,(void *)statsDumper,(void *)&aggrDumperJob);
252254
253 - alarm(PERIOD-(dumptime%PERIOD)+1);
 255+ needdump=0;
 256+ alarm(PERIOD-(dumptime%PERIOD));
254257 }
255258
256259 /* TCP connection handling logic - unsafe dump of data in DB - should be avoided at large datasets */
@@ -280,6 +283,7 @@
281284 /* Event handling - most of them are not used or should not be used due to reentry possibilities */
282285
283286 void alarmed() {
 287+ alarm(0);
284288 needdump=1;
285289 }
286290
@@ -299,4 +303,4 @@
300304 void truncatedb() {
301305 unsigned int count;
302306 db->truncate(db,NULL,&count,0);
303 -}
\ No newline at end of file
 307+}

Status & tagging log