Index: trunk/webstatscollector/export.c |
— | — | @@ -28,10 +28,6 @@ |
29 | 29 | bzero(&key,sizeof(key)); |
30 | 30 | bzero(&data,sizeof(data)); |
31 | 31 | |
32 | | - if (db==NULL) { |
33 | | - db_create(&db,NULL,0); |
34 | | - db->open(db,NULL,"stats.db",NULL,DB_BTREE,0,0); |
35 | | - } |
36 | 32 | db->cursor(db,NULL,&c,0); |
37 | 33 | while(c->c_get(c, &key, &data, DB_NEXT )==0) { |
38 | 34 | entry=data.data; |
— | — | @@ -44,7 +40,7 @@ |
45 | 41 | |
46 | 42 | /* Get EVENT */ |
47 | 43 | fprintf(fd,"%s %s %llu %llu\n", |
48 | | - project,(page==NULL?page:"-"), |
| 44 | + project,(page?page:"-"), |
49 | 45 | entry->wc_count, entry->wc_bytes); |
50 | 46 | } |
51 | 47 | c->c_close(c); |
Index: trunk/webstatscollector/collector.c |
— | — | @@ -128,9 +128,11 @@ |
129 | 129 | char keytext[1200]; |
130 | 130 | int r; |
131 | 131 | |
| 132 | + unsigned long long serial; |
| 133 | + |
132 | 134 | struct wcstats incoming; |
133 | 135 | /* project count bytesize page */ |
134 | | - const char msgformat[]="%127s %llu %llu %1023[^\n]"; |
| 136 | + const char msgformat[]="%llu %127s %llu %llu %1023[^\n]"; |
135 | 137 | |
136 | 138 | buf[l]=0; |
137 | 139 | pp=buf; |
— | — | @@ -143,11 +145,11 @@ |
144 | 146 | return; |
145 | 147 | } |
146 | 148 | bzero(&incoming,sizeof(incoming)); |
147 | | - r=sscanf(p,msgformat,(char *)&project, |
| 149 | + r=sscanf(p,msgformat,&serial,(char *)&project, |
148 | 150 | &incoming.wc_count, |
149 | 151 | &incoming.wc_bytes, |
150 | 152 | (char *)&title); |
151 | | - if (r<4) |
| 153 | + if (r<5) |
152 | 154 | continue; |
153 | 155 | snprintf(keytext,1499,"%s:%s",project,title); |
154 | 156 | |
— | — | @@ -170,10 +172,10 @@ |
171 | 173 | void increaseStatistics(DB *db, char *keytext, struct wcstats *incoming ) { |
172 | 174 | struct wcstats *old; |
173 | 175 | DBT key,data; |
174 | | - |
| 176 | + |
175 | 177 | bzero(&key,sizeof(key)); |
176 | 178 | key.data=keytext; |
177 | | - key.size=strlen(keytext); |
| 179 | + key.size=strlen(keytext)+1; |
178 | 180 | |
179 | 181 | bzero(&data,sizeof(data)); |
180 | 182 | |
— | — | @@ -227,7 +229,7 @@ |
228 | 230 | pthread_t dumper,aggrdumper; |
229 | 231 | static struct dumperjob dumperJob, aggrDumperJob; |
230 | 232 | DB *olddb,*oldaggr; |
231 | | - time_t dumptime; |
| 233 | + time_t dumptime=0; |
232 | 234 | |
233 | 235 | time(&dumptime); |
234 | 236 | |
— | — | @@ -249,7 +251,8 @@ |
250 | 252 | |
251 | 253 | pthread_create(&aggrdumper,NULL,(void *)statsDumper,(void *)&aggrDumperJob); |
252 | 254 | |
253 | | - alarm(PERIOD-(dumptime%PERIOD)+1); |
| 255 | + needdump=0; |
| 256 | + alarm(PERIOD-(dumptime%PERIOD)); |
254 | 257 | } |
255 | 258 | |
256 | 259 | /* TCP connection handling logic - unsafe dump of data in DB - should be avoided at large datasets */ |
— | — | @@ -280,6 +283,7 @@ |
281 | 284 | /* Event handling - most of them are not used or should not be used due to reentry possibilities */ |
282 | 285 | |
283 | 286 | void alarmed() { |
| 287 | + alarm(0); |
284 | 288 | needdump=1; |
285 | 289 | } |
286 | 290 | |
— | — | @@ -299,4 +303,4 @@ |
300 | 304 | void truncatedb() { |
301 | 305 | unsigned int count; |
302 | 306 | db->truncate(db,NULL,&count,0); |
303 | | -} |
\ No newline at end of file |
| 307 | +} |