void aap_log_append(int sent, struct args *arg, int reply) { struct log *l = arg->log; /* we do not incude the body, only the headers et al.. */ struct log_entry *le=new_log_entry(arg->res.body_start-3); char *data_to=((char *)le)+sizeof(struct log_entry); le->t = aap_get_time(); le->sent_bytes = sent; le->reply = reply; le->received_bytes = arg->res.body_start + arg->res.content_len; MEMCPY(data_to, arg->res.data, arg->res.body_start-4); le->raw.str = data_to; le->raw.len = arg->res.body_start-4; le->url.str = (data_to + (size_t)(arg->res.url-arg->res.data)); le->url.len = arg->res.url_len; le->from = arg->from; le->method.str = data_to; le->method.len = arg->res.method_len; le->protocol = arg->res.protocol; le->next = 0; mt_lock( &l->log_lock ); if(l->log_head) { l->log_tail->next = le; l->log_tail = le; } else { l->log_head = le; l->log_tail = le; } mt_unlock( &l->log_lock ); }
void add_log_entry(log_type *log, const char *entry) { list_node *node = new_log_entry(); node->log_entry = entry; if(log==NULL) return ; pthread_mutex_lock(&log->lock); node->next = log->log_entry_list.next; log->log_entry_list.next = node; log->num_entries++; pthread_mutex_unlock(&log->lock); }
/** * Adds a log entry to the log. * A new list node is created and filled with the passed entry. * * \param log log_type where the entry is stored * \param entry Entry to be stored in the log */ void add_log_entry(log_type *log, const char *entry) { list_node *node = new_log_entry(); node->log_entry = entry; pthread_mutex_lock(&log->lock); /* place the node in the head position */ node->next = log->log_entry_list.next; log->log_entry_list.next = node; /* increment num_entries to reflect the change */ log->num_entries++; pthread_mutex_unlock(&log->lock); }