src/server/daemon/log.c

changeset 490
d218607f5a7e
parent 443
ef3c8a0e1fee
equal deleted inserted replaced
489:921f83a8943f 490:d218607f5a7e
105 0, // verbose 105 0, // verbose
106 0 // debug 106 0 // debug
107 }; 107 };
108 108
109 int init_logging(void) { 109 int init_logging(void) {
110 log_dup_list = cxPointerLinkedListCreate(cxDefaultAllocator, cx_cmp_ptr); 110 log_dup_list = cxLinkedListCreate(cxDefaultAllocator, NULL, CX_STORE_POINTERS);
111 return log_dup_list == NULL; 111 return log_dup_list == NULL;
112 } 112 }
113 113
114 int init_log_file(LogConfig *cfg) { 114 int init_log_file(LogConfig *cfg) {
115 if(is_initialized) { 115 if(is_initialized) {
199 char *msg = malloc(len + 1); 199 char *msg = malloc(len + 1);
200 memcpy(msg, str, len); 200 memcpy(msg, str, len);
201 msg[len] = '\n'; 201 msg[len] = '\n';
202 202
203 pthread_mutex_lock(&mutex); 203 pthread_mutex_lock(&mutex);
204 CxIterator i = cxListIterator(log_dup_list, 0); 204 CxIterator i = cxListIterator(log_dup_list);
205 cx_foreach(LogDup *, dup, i) { 205 cx_foreach(LogDup *, dup, i) {
206 dup->write(dup->cookie, msg, len + 1); 206 dup->write(dup->cookie, msg, len + 1);
207 } 207 }
208 pthread_mutex_unlock(&mutex); 208 pthread_mutex_unlock(&mutex);
209 209
253 pthread_mutex_unlock(&mutex); 253 pthread_mutex_unlock(&mutex);
254 } 254 }
255 255
256 void log_remove_logdup(LogDup *ldup) { 256 void log_remove_logdup(LogDup *ldup) {
257 pthread_mutex_lock(&mutex); 257 pthread_mutex_lock(&mutex);
258 CxMutIterator i = cxListMutIterator(log_dup_list, 0); 258 CxMutIterator i = cxListMutIterator(log_dup_list);
259 WSBool finished = 0; 259 WSBool finished = 0;
260 cx_foreach(LogDup *, dup, i) { 260 cx_foreach(LogDup *, dup, i) {
261 if(finished) break; 261 if(finished) break;
262 if(dup == ldup) { 262 if(dup == ldup) {
263 cxIteratorFlagRemoval(i); 263 cxIteratorFlagRemoval(i);
381 */ 381 */
382 LogFile* get_access_log_file(cxstring file) { 382 LogFile* get_access_log_file(cxstring file) {
383 // TODO: this looks dubious 383 // TODO: this looks dubious
384 384
385 if(!access_log_files) { 385 if(!access_log_files) {
386 access_log_files = cxHashMapCreate(cxDefaultAllocator, 4); 386 access_log_files = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 4);
387 } 387 }
388 388
389 if(file.ptr == NULL || file.length == 0) { 389 if(file.ptr == NULL || file.length == 0) {
390 return NULL; 390 return NULL;
391 } 391 }

mercurial