From: Nick Mathewson Date: Tue, 27 Jan 2009 21:10:31 +0000 (+0000) Subject: Remove all trailing whitespace in all the source files. X-Git-Tag: release-2.0.1-alpha~122 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9993137cbbd9508dbf28e431e0f84d809c516128;p=libevent Remove all trailing whitespace in all the source files. svn:r1063 --- diff --git a/buffer.c b/buffer.c index 6e80cbe9..518d6de1 100644 --- a/buffer.c +++ b/buffer.c @@ -119,7 +119,7 @@ evbuffer_chain_new(size_t size) size_t to_alloc; size += EVBUFFER_CHAIN_SIZE; - + /* get the next largest memory that can hold the buffer */ to_alloc = MIN_BUFFER_SIZE; while (to_alloc < size) @@ -288,7 +288,7 @@ evbuffer_commit_space(struct evbuffer *buf, size_t size) { struct evbuffer_chain *chain = buf->last; - if (chain == NULL || + if (chain == NULL || chain->buffer_len - chain->off - chain->misalign < size) return (-1); @@ -304,7 +304,7 @@ evbuffer_commit_space(struct evbuffer *buf, size_t size) (dst)->previous_to_last = NULL; \ (dst)->total_len = 0; \ } while (0) - + #define COPY_CHAIN(dst, src) do { \ (dst)->first = (src)->first; \ (dst)->previous_to_last = (src)->previous_to_last; \ @@ -327,7 +327,7 @@ evbuffer_commit_space(struct evbuffer *buf, size_t size) if ((dst)->previous_to_last == NULL) \ (dst)->previous_to_last = (src)->last; \ } while (0) - + int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf) @@ -502,7 +502,7 @@ evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst, src->first = chain; if (src->first == src->last) src->previous_to_last = NULL; - + dst->total_len += nread; } @@ -569,7 +569,7 @@ evbuffer_pullup(struct evbuffer *buf, ssize_t size) memcpy(buffer, chain->buffer + chain->misalign, chain->off); size -= chain->off; buffer += chain->off; - + evbuffer_chain_free(chain); } @@ -802,7 +802,7 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen) chain->buffer + chain->misalign, chain->off); chain->misalign = 0; - + memcpy(chain->buffer + chain->off, data, datlen); chain->off += datlen; buf->total_len += datlen; @@ -822,7 +822,7 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen) tmp = evbuffer_chain_new(to_alloc); if (tmp == NULL) return (-1); - + if (remain) { memcpy(chain->buffer + chain->misalign + chain->off, data, remain); @@ -1260,7 +1260,7 @@ evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t fd, res = sendfile(fd, info->fd, &offset, chain->off); if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) { /* if this is EGAIN or EINTR return 0; otherwise, -1 */ - return (0); + return (0); } return (res); #endif @@ -1449,11 +1449,11 @@ evbuffer_add_file(struct evbuffer *outbuf, int fd, info = EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_fd, chain); info->fd = fd; - + evbuffer_chain_insert(outbuf, chain); } else #endif -#if defined(HAVE_MMAP) +#if defined(HAVE_MMAP) if (use_mmap) { void *mapped = mmap(NULL, length + offset, PROT_READ, #ifdef MAP_NOCACHE @@ -1483,10 +1483,10 @@ evbuffer_add_file(struct evbuffer *outbuf, int fd, chain->buffer = mapped; chain->buffer_len = length + offset; chain->off = length + offset; - + info = EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_fd, chain); info->fd = fd; - + evbuffer_chain_insert(outbuf, chain); /* we need to subtract whatever we don't need */ @@ -1509,7 +1509,7 @@ evbuffer_add_file(struct evbuffer *outbuf, int fd, length -= read; } - + close(fd); } diff --git a/bufferevent.c b/bufferevent.c index 46b8e524..56f5d110 100644 --- a/bufferevent.c +++ b/bufferevent.c @@ -81,7 +81,7 @@ bufferevent_add(struct event *ev, int timeout) return (event_add(ev, ptv)); } -/* +/* * This callback is executed when the size of the input buffer changes. * We use it to apply back pressure on the reading side. */ @@ -398,7 +398,7 @@ bufferevent_free(struct bufferevent *bufev) bufferevent_filter_free(filter); } - + while ((filter = TAILQ_FIRST(&bufev->output_filters)) != NULL) { bufferevent_filter_remove(bufev, BEV_OUTPUT, filter); @@ -469,7 +469,7 @@ bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf) if (evbuffer_add_buffer(output, buf) == -1) return (-1); - + return (bufferevent_write_closure(bufev, len > 0)); } @@ -648,7 +648,7 @@ bufferevent_filter_remove(struct bufferevent *bufev, if (filter->free_context) filter->free_context(filter->ctx); - + } static int diff --git a/devpoll.c b/devpoll.c index 63f3df38..a31745ed 100644 --- a/devpoll.c +++ b/devpoll.c @@ -102,8 +102,8 @@ devpoll_queue(struct devpollop *devpollop, int fd, int events) { if (devpollop->nchanges >= devpollop->nevents) { /* - * Change buffer is full, must commit it to /dev/poll before - * adding more + * Change buffer is full, must commit it to /dev/poll before + * adding more */ if (devpoll_commit(devpollop) != 0) return(-1); @@ -228,7 +228,7 @@ devpoll_add(struct event_base *base, int fd, short old, short events, void *p) int res; (void)p; - /* + /* * It's not necessary to OR the existing read/write events that we * are currently interested in with the new event we are adding. * The /dev/poll driver ORs any new events with the existing events @@ -262,8 +262,8 @@ devpoll_del(struct event_base *base, int fd, short old, short events, void *p) /* * The only way to remove an fd from the /dev/poll monitored set is - * to use POLLREMOVE by itself. This removes ALL events for the fd - * provided so if we care about two events and are only removing one + * to use POLLREMOVE by itself. This removes ALL events for the fd + * provided so if we care about two events and are only removing one * we must re-add the other event after POLLREMOVE. */ diff --git a/evdns.c b/evdns.c index ed892d56..0dec001c 100644 --- a/evdns.c +++ b/evdns.c @@ -1513,7 +1513,7 @@ evdns_request_data_build(const char *const name, const int name_len, if (j < 0) { return (int)j; } - + APPEND16(type); APPEND16(class); diff --git a/event.c b/event.c index c3b4f3f1..99263f0a 100644 --- a/event.c +++ b/event.c @@ -38,7 +38,7 @@ #ifndef WIN32 #ifdef HAVE_SYS_TIME_H #include -#else +#else #include #endif #endif @@ -399,7 +399,7 @@ event_reinit(struct event_base *base) EVLIST_ACTIVE); base->sig.ev_signal_added = 0; } - + if (base->evsel->dealloc != NULL) base->evsel->dealloc(base); base->evbase = evsel->init(base); @@ -623,10 +623,10 @@ event_process_active(struct event_base *base) event_queue_remove(base, ev, EVLIST_ACTIVE); else event_del_internal(ev); - + event_debug(( "event_process_active: event: %p, %s%scall %p", - ev, + ev, ev->ev_res & EV_READ ? "EV_READ " : " ", ev->ev_res & EV_WRITE ? "EV_WRITE " : " ", ev->ev_callback)); @@ -769,13 +769,13 @@ event_base_loop(struct event_base *base, int flags) if (!base->event_count_active && !(flags & EVLOOP_NONBLOCK)) { timeout_next(base, &tv_p); } else { - /* + /* * if we have active events, we just poll new events * without waiting. */ evutil_timerclear(&tv); } - + /* If we have no events, we just exit */ if (!event_haveevents(base)) { event_debug(("%s: no events registered.", __func__)); @@ -1119,7 +1119,7 @@ event_add_internal(struct event *ev, const struct timeval *tv) event_queue_insert(base, ev, EVLIST_INSERTED); } - /* + /* * we should change the timout state only if the previous event * addition succeeded. */ @@ -1133,13 +1133,13 @@ event_add_internal(struct event *ev, const struct timeval *tv) if (ev->ev_closure == event_persist_closure) ev->ev_io_timeout = *tv; - /* + /* * we already reserved memory above for the case where we * are not replacing an exisiting timeout. */ if (ev->ev_flags & EVLIST_TIMEOUT) event_queue_remove(base, ev, EVLIST_TIMEOUT); - + /* Check if it is active due to a timeout. Rescheduling * this timeout before the callback can be executed * removes it from the active list. */ @@ -1154,7 +1154,7 @@ event_add_internal(struct event *ev, const struct timeval *tv) *ev->ev_pncalls = 0; } } - + event_queue_remove(base, ev, EVLIST_ACTIVE); } @@ -1181,7 +1181,7 @@ event_del(struct event *ev) int res; EVTHREAD_ACQUIRE_LOCK(ev->ev_base, EVTHREAD_WRITE, th_base_lock); - + res = event_del_internal(ev); EVTHREAD_RELEASE_LOCK(ev->ev_base, EVTHREAD_WRITE, th_base_lock); @@ -1448,7 +1448,7 @@ event_get_version(void) return (VERSION); } -/* +/* * No thread-safe interface needed - the information should be the same * for all threads. */ diff --git a/event_rpcgen.py b/event_rpcgen.py index b3770830..0dd0786f 100755 --- a/event_rpcgen.py +++ b/event_rpcgen.py @@ -59,10 +59,10 @@ class Struct: class StructCCode(Struct): """ Knows how to generate C code for a struct """ - + def __init__(self, name): Struct.__init__(self, name) - + def PrintTags(self, file): """Prints the tag definitions for a structure.""" print >>file, '/* Tag definition for %s */' % self._name @@ -106,7 +106,7 @@ void %(name)s_clear(struct %(name)s *); void %(name)s_marshal(struct evbuffer *, const struct %(name)s *); int %(name)s_unmarshal(struct %(name)s *, struct evbuffer *); int %(name)s_complete(struct %(name)s *); -void evtag_marshal_%(name)s(struct evbuffer *, ev_uint32_t, +void evtag_marshal_%(name)s(struct evbuffer *, ev_uint32_t, const struct %(name)s *); int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t, struct %(name)s *);""" % { 'name' : self._name } @@ -161,7 +161,7 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t, if entry.Array(): self.PrintIndented(file, '', entry.CodeAdd()) print >>file, '' - + # Assigning for entry in self._entries: self.PrintIndented(file, '', entry.CodeAssign()) @@ -171,7 +171,7 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t, for entry in self._entries: self.PrintIndented(file, '', entry.CodeGet()) print >>file, '' - + # Clearing print >>file, ( 'void\n' '%(name)s_clear(struct %(name)s *tmp)\n' @@ -187,7 +187,7 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t, '%(name)s_free(struct %(name)s *tmp)\n' '{' ) % { 'name' : self._name } - + for entry in self._entries: self.PrintIndented(file, ' ', entry.CodeFree('tmp')) @@ -214,7 +214,7 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t, print >>file, ' }' print >>file, '}\n' - + # Unmarshaling print >>file, ('int\n' '%(name)s_unmarshal(struct %(name)s *tmp, ' @@ -269,7 +269,7 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t, code = TranslateList(code, entry.GetTranslation()) self.PrintIndented( file, ' ', code) - + self.PrintIndented( file, ' ', entry.CodeComplete('msg', entry.GetVarName('msg'))) @@ -361,7 +361,7 @@ class Entry: def MakeArray(self, yes=1): self._array = yes - + def MakeOptional(self): self._optional = 1 @@ -397,7 +397,7 @@ class Entry: mapping[k] = v return mapping - + def GetVarName(self, var): return '%(var)s->%(name)s_data' % self.GetTranslation({ 'var' : var }) @@ -406,7 +406,7 @@ class Entry: def GetFuncName(self): return '%s_%s_get' % (self._struct.Name(), self._name) - + def GetDeclaration(self, funcname): code = [ 'int %s(struct %s *, %s *);' % ( funcname, self._struct.Name(), self._ctype ) ] @@ -426,13 +426,13 @@ class Entry: code = '\n'.join(code) code = code % self.GetTranslation() return code.split('\n') - + def AssignFuncName(self): return '%s_%s_assign' % (self._struct.Name(), self._name) - + def AddFuncName(self): return '%s_%s_add' % (self._struct.Name(), self._name) - + def AssignDeclaration(self, funcname): code = [ 'int %s(struct %s *, const %s);' % ( funcname, self._struct.Name(), self._ctype ) ] @@ -455,7 +455,7 @@ class Entry: code = [ '%s->%s_set = 0;' % (structname, self.Name()) ] return code - + def CodeComplete(self, structname, var_name): return [] @@ -496,15 +496,15 @@ class EntryBytes(Entry): code = [ 'int %s(struct %s *, %s **);' % ( funcname, self._struct.Name(), self._ctype ) ] return code - + def AssignDeclaration(self, funcname): code = [ 'int %s(struct %s *, const %s *);' % ( funcname, self._struct.Name(), self._ctype ) ] return code - + def Declaration(self): dcl = ['ev_uint8_t %s_data[%s];' % (self._name, self._length)] - + return dcl def CodeGet(self): @@ -520,7 +520,7 @@ class EntryBytes(Entry): ' return (0);', '}' ] return code - + def CodeAssign(self): name = self._name code = [ 'int', @@ -534,7 +534,7 @@ class EntryBytes(Entry): ' return (0);', '}' ] return code - + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): code = [ 'if (evtag_unmarshal_fixed(%(buf)s, %(tag)s, ' '%(var)s, %(varlen)s) == -1) {', @@ -560,7 +560,7 @@ class EntryBytes(Entry): structname, self._name, structname, self._name)] return code - + def CodeInitialize(self, name): code = ['memset(%s->%s_data, 0, sizeof(%s->%s_data));' % ( name, self._name, name, self._name)] @@ -588,11 +588,11 @@ class EntryInt(Entry): self._marshal_type = 'int64' def GetInitializer(self): - return "0" + return "0" def CodeArrayFree(self, var): return [] - + def CodeArrayAssign(self, varname, srcvar): return [ '%(varname)s = %(srcvar)s;' % { 'varname' : varname, 'srcvar' : srcvar } ] @@ -695,7 +695,7 @@ class EntryString(Entry): }""" % self.GetTranslation() return code.split('\n') - + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): code = ['if (evtag_unmarshal_string(%(buf)s, %(tag)s, &%(var)s) == -1) {', ' event_warnx("%%s: failed to unmarshal %(name)s", __func__);', @@ -722,14 +722,14 @@ class EntryString(Entry): ] return code - + def CodeInitialize(self, name): code = ['%s->%s_data = NULL;' % (name, self._name)] return code def CodeFree(self, name): code = ['if (%s->%s_data != NULL)' % (name, self._name), - ' free (%s->%s_data); ' % (name, self._name)] + ' free (%s->%s_data);' % (name, self._name)] return code @@ -750,7 +750,7 @@ class EntryStruct(Entry): self._optaddarg = False def GetInitializer(self): - return "NULL" + return "NULL" def GetVarLen(self, var): return '-1' @@ -791,7 +791,7 @@ class EntryStruct(Entry): ' %(refname)s_clear(%(var)s);', ' return (-1);', '}' ] - + return TranslateList(code, self.GetTranslation({ 'var' : var, 'srcvar' : srcvar})) @@ -813,7 +813,7 @@ class EntryStruct(Entry): ' return (0);', '}' ] return code - + def CodeAssign(self): name = self._name code = """int @@ -853,7 +853,7 @@ class EntryStruct(Entry): return (-1); }""" % self.GetTranslation() return code.split('\n') - + def CodeComplete(self, structname, var_name): code = [ 'if (%(structname)s->%(name)s_set && ' '%(refname)s_complete(%(var)s) == -1)', @@ -862,7 +862,7 @@ class EntryStruct(Entry): return TranslateList(code, self.GetTranslation({ 'structname' : structname, 'var' : var_name })) - + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): code = ['%(var)s = %(refname)s_new();', 'if (%(var)s == NULL)', @@ -894,7 +894,7 @@ class EntryStruct(Entry): ] return code - + def CodeInitialize(self, name): code = ['%s->%s_data = NULL;' % (name, self._name)] return code @@ -919,7 +919,7 @@ class EntryVarBytes(Entry): self._ctype = 'ev_uint8_t *' def GetInitializer(self): - return "NULL" + return "NULL" def GetVarLen(self, var): return '%(var)s->%(name)s_length' % self.GetTranslation({ 'var' : var }) @@ -932,12 +932,12 @@ class EntryVarBytes(Entry): code = [ 'int %s(struct %s *, %s *, ev_uint32_t *);' % ( funcname, self._struct.Name(), self._ctype ) ] return code - + def AssignDeclaration(self, funcname): code = [ 'int %s(struct %s *, const %s, ev_uint32_t);' % ( funcname, self._struct.Name(), self._ctype ) ] return code - + def CodeAssign(self): name = self._name code = [ 'int', @@ -957,7 +957,7 @@ class EntryVarBytes(Entry): ' return (0);', '}' ] return code - + def CodeGet(self): name = self._name code = [ 'int', @@ -1009,7 +1009,7 @@ class EntryVarBytes(Entry): ] return code - + def CodeInitialize(self, name): code = ['%s->%s_data = NULL;' % (name, self._name), '%s->%s_length = 0;' % (name, self._name) ] @@ -1047,7 +1047,7 @@ class EntryArray(Entry): self._entry.GetVarName = GetVarName def GetInitializer(self): - return "NULL" + return "NULL" def GetVarName(self, var_name): return var_name @@ -1061,19 +1061,19 @@ class EntryArray(Entry): 'int %(funcname)s(struct %(parent_name)s *, int, %(ctype)s *);' % self.GetTranslation({ 'funcname' : funcname }) ] return code - + def AssignDeclaration(self, funcname): code = [ 'int %s(struct %s *, int, const %s);' % ( funcname, self._struct.Name(), self._ctype ) ] return code - + def AddDeclaration(self, funcname): code = [ '%(ctype)s %(optpointer)s ' '%(funcname)s(struct %(parent_name)s *msg%(optaddarg)s);' % \ self.GetTranslation({ 'funcname' : funcname }) ] return code - + def CodeGet(self): code = """int %(parent_name)s_%(name)s_get(struct %(parent_name)s *msg, int offset, @@ -1086,7 +1086,7 @@ class EntryArray(Entry): }""" % self.GetTranslation() return code.split('\n') - + def CodeAssign(self): code = [ 'int', @@ -1108,7 +1108,7 @@ class EntryArray(Entry): '}' ], self.GetTranslation()) return code - + def CodeAdd(self): codearrayadd = self._entry.CodeArrayAdd( 'msg->%(name)s_data[msg->%(name)s_length - 1]' % self.GetTranslation(), @@ -1131,7 +1131,7 @@ class EntryArray(Entry): ' }' ] code = TranslateList(code, self.GetTranslation()) - + code += map(lambda x: ' ' + x, codearrayadd) code += TranslateList([ @@ -1167,7 +1167,7 @@ class EntryArray(Entry): '}' ] return code - + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): translate = self.GetTranslation({ 'var' : var_name, 'buf' : buf, @@ -1209,7 +1209,7 @@ class EntryArray(Entry): ] code = "\n".join(code) % self.GetTranslation({ 'var' : var_name }) - + return code.split('\n') def CodeClear(self, structname): @@ -1231,8 +1231,8 @@ class EntryArray(Entry): code += map(lambda x: ' ' + x, codearrayfree) code += [ ' }' ] - - code += TranslateList([ + + code += TranslateList([ ' free(%(structname)s->%(name)s_data);', ' %(structname)s->%(name)s_data = NULL;', ' %(structname)s->%(name)s_set = 0;', @@ -1242,7 +1242,7 @@ class EntryArray(Entry): ], translate) return code - + def CodeInitialize(self, name): code = ['%s->%s_data = NULL;' % (name, self._name), '%s->%s_length = 0;' % (name, self._name), @@ -1268,7 +1268,7 @@ class EntryArray(Entry): def NormalizeLine(line): global white global cppcomment - + line = cppcomment.sub('', line) line = line.strip() line = white.sub(' ', line) @@ -1361,7 +1361,7 @@ def ProcessOneEntry(factory, newstruct, entry): sys.exit(1) structs = [] - + if optional: newentry.MakeOptional() if array: @@ -1422,7 +1422,7 @@ def GetNextStruct(file): line = file.readline() if not line: break - + line_count += 1 line = line[:-1] @@ -1448,7 +1448,7 @@ def GetNextStruct(file): if re.match(r'#include ["<].*[>"]', line): cppdirect.append(line) continue - + if re.match(r'^#(if( |def)|endif)', line): cppdirect.append(line) continue @@ -1484,9 +1484,9 @@ def GetNextStruct(file): # Remove any comments, that might be in there data = re.sub(r'/\*.*\*/', '', data) - + return data - + def Parse(factory, file): """ @@ -1509,14 +1509,14 @@ def Parse(factory, file): class CCodeGenerator: def __init__(self): pass - + def GuardName(self, name): name = '_'.join(name.split('.')) name = '_'.join(name.split('/')) guard = '_' + name.upper() + '_' - + return guard - + def HeaderPreamble(self, name): guard = self.GuardName(name) pre = ( @@ -1526,19 +1526,19 @@ class CCodeGenerator: '#ifndef %s\n' '#define %s\n\n' ) % ( name, guard, guard) - + # insert stdint.h - let's hope everyone has it pre += ( '#include \n' '#ifdef _EVENT_HAVE_STDINT_H\n' '#include \n' '#endif\n' ) - + for statement in headerdirect: pre += '%s\n' % statement if headerdirect: pre += '\n' - + pre += ( '#define EVTAG_HAS(msg, member) ((msg)->member##_set == 1)\n' '#define EVTAG_ASSIGN(msg, member, args...) ' @@ -1549,19 +1549,19 @@ class CCodeGenerator: '(*(msg)->base->member##_add)(msg, ## args)\n' '#define EVTAG_LEN(msg, member) ((msg)->member##_length)\n' ) - + return pre - + def HeaderPostamble(self, name): guard = self.GuardName(name) return '#endif /* %s */' % guard - + def BodyPreamble(self, name): global _NAME global _VERSION - + header_file = '.'.join(name.split('.')[:-1]) + '.gen.h' - + pre = ( '/*\n' ' * Automatically generated from %s\n' ' * by %s/%s. DO NOT EDIT THIS FILE.\n' @@ -1575,24 +1575,24 @@ class CCodeGenerator: '#include \n' '#include \n\n' ) - + for statement in cppdirect: pre += '%s\n' % statement - + pre += '\n#include "%s"\n\n' % header_file - + pre += 'void event_err(int eval, const char *fmt, ...);\n' pre += 'void event_warn(const char *fmt, ...);\n' pre += 'void event_errx(int eval, const char *fmt, ...);\n' pre += 'void event_warnx(const char *fmt, ...);\n\n' - + return pre def HeaderFilename(self, filename): - return '.'.join(filename.split('.')[:-1]) + '.gen.h' + return '.'.join(filename.split('.')[:-1]) + '.gen.h' def CodeFilename(self, filename): - return '.'.join(filename.split('.')[:-1]) + '.gen.c' + return '.'.join(filename.split('.')[:-1]) + '.gen.c' def Struct(self, name): return StructCCode(name) @@ -1652,7 +1652,7 @@ def Generate(factory, filename): for entry in entities: entry.PrintCode(impl_fp) impl_fp.close() - + def main(argv): if len(argv) < 2 or not argv[1]: print >>sys.stderr, 'Need RPC description file as first argument.' diff --git a/event_tagging.c b/event_tagging.c index cb311b8d..a74c3544 100644 --- a/event_tagging.c +++ b/event_tagging.c @@ -496,7 +496,7 @@ evtag_unmarshal_fixed(struct evbuffer *src, ev_uint32_t need_tag, void *data, if (tag_len != len) return (-1); - + evbuffer_remove(src, data, len); return (0); } diff --git a/evport.c b/evport.c index e553c005..b349973a 100644 --- a/evport.c +++ b/evport.c @@ -21,7 +21,7 @@ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* @@ -41,7 +41,7 @@ * * evport_add and evport_del update this data structure. evport_dispatch uses it * to determine where to callback when an event occurs (which it gets from - * port_getn). + * port_getn). * * Helper functions are used: grow() grows the file descriptor array as * necessary when large fd's come in. reassociate() takes care of maintaining @@ -220,7 +220,7 @@ grow(struct evport_data *epdp, int factor) if (NULL == tmp) return -1; epdp->ed_fds = tmp; - memset((char*) (epdp->ed_fds + oldsize), 0, + memset((char*) (epdp->ed_fds + oldsize), 0, (newsize - oldsize)*sizeof(struct fd_info)); epdp->ed_nevents = newsize; @@ -303,7 +303,7 @@ evport_dispatch(struct event_base *base, struct timeval *tv) } } - if ((res = port_getn(epdp->ed_port, pevtlist, EVENTS_PER_GETN, + if ((res = port_getn(epdp->ed_port, pevtlist, EVENTS_PER_GETN, (unsigned int *) &nevents, ts_p)) == -1) { if (errno == EINTR || errno == EAGAIN) { evsig_process(base); @@ -318,7 +318,7 @@ evport_dispatch(struct event_base *base, struct timeval *tv) } else if (base->sig.evsig_caught) { evsig_process(base); } - + event_debug(("%s: port_getn reports %d events", __func__, nevents)); for (i = 0; i < nevents; ++i) { @@ -331,7 +331,7 @@ evport_dispatch(struct event_base *base, struct timeval *tv) epdp->ed_pending[i] = fd; /* - * Figure out what kind of event it was + * Figure out what kind of event it was * (because we have to pass this to the callback) */ res = 0; diff --git a/evrpc.c b/evrpc.c index 7937824c..be4cea65 100644 --- a/evrpc.c +++ b/evrpc.c @@ -132,7 +132,7 @@ evrpc_add_hook(void *vbase, hook = mm_calloc(1, sizeof(struct evrpc_hook)); assert(hook != NULL); - + hook->process = cb; hook->process_arg = cb_arg; TAILQ_INSERT_TAIL(head, hook, next); @@ -234,7 +234,7 @@ evrpc_register_rpc(struct evrpc_base *base, struct evrpc *rpc, constructed_uri, evrpc_request_cb, rpc); - + mm_free(constructed_uri); return (0); @@ -256,7 +256,7 @@ evrpc_unregister_rpc(struct evrpc_base *base, const char *name) return (-1); } TAILQ_REMOVE(&base->registered_rpcs, rpc, next); - + mm_free((char *)rpc->uri); mm_free(rpc); @@ -558,20 +558,20 @@ evrpc_pool_add_connection(struct evrpc_pool *pool, if (pool->base != NULL) evhttp_connection_set_base(connection, pool->base); - /* + /* * unless a timeout was specifically set for a connection, * the connection inherits the timeout from the pool. */ if (connection->timeout == -1) connection->timeout = pool->timeout; - /* + /* * if we have any requests pending, schedule them with the new * connections. */ if (TAILQ_FIRST(&pool->requests) != NULL) { - struct evrpc_request_wrapper *request = + struct evrpc_request_wrapper *request = TAILQ_FIRST(&pool->requests); TAILQ_REMOVE(&pool->requests, request, next); evrpc_schedule_request(connection, request); @@ -617,7 +617,7 @@ evrpc_pool_find_connection(struct evrpc_pool *pool) /* * Prototypes responsible for evrpc scheduling and hooking - */ + */ static void evrpc_schedule_request_closure(void *ctx, enum EVRPC_HOOK_RESULT); @@ -702,7 +702,7 @@ evrpc_schedule_request_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res) goto error; if (pool->timeout > 0) { - /* + /* * a timeout after which the whole rpc is going to be aborted. */ struct timeval tv; @@ -775,7 +775,7 @@ evrpc_make_request(struct evrpc_request_wrapper *ctx) /* we better have some available connections on the pool */ assert(TAILQ_FIRST(&pool->connections) != NULL); - /* + /* * if no connection is available, we queue the request on the pool, * the next time a connection is empty, the rpc will be send on that. */ @@ -830,7 +830,7 @@ evrpc_reply_done(struct evhttp_request *req, void *arg) struct evrpc_request_wrapper *ctx = arg; struct evrpc_pool *pool = ctx->pool; int hook_res = EVRPC_CONTINUE; - + /* cancel any timeout we might have scheduled */ event_del(&ctx->ev_timeout); @@ -907,7 +907,7 @@ evrpc_reply_done_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res) } (*ctx->cb)(&status, ctx->request, ctx->reply, ctx->cb_arg); - + evrpc_request_wrapper_free(ctx); /* the http layer owned the orignal request structure, but if we diff --git a/evutil.c b/evutil.c index 4397025d..542ba31e 100644 --- a/evutil.c +++ b/evutil.c @@ -184,7 +184,7 @@ evutil_make_socket_nonblocking(evutil_socket_t fd) if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) { event_warn("fcntl(O_NONBLOCK)"); return -1; -} +} #endif return 0; } diff --git a/http.c b/http.c index a9eeba25..03fa95b6 100644 --- a/http.c +++ b/http.c @@ -109,11 +109,11 @@ #define NI_NUMERICSERV 2 static int -fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, +fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { struct sockaddr_in *sin = (struct sockaddr_in *)sa; - + if (serv != NULL) { char tmpserv[16]; evutil_snprintf(tmpserv, sizeof(tmpserv), @@ -131,11 +131,11 @@ fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, return (0); } else { struct hostent *hp; - hp = gethostbyaddr((char *)&sin->sin_addr, + hp = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr), AF_INET); if (hp == NULL) return (-2); - + if (strlcpy(host, hp->h_name, hostlen) >= hostlen) return (-1); else @@ -262,7 +262,7 @@ html_replace(char ch, char *buf) /* Echo the character back */ buf[0] = ch; buf[1] = '\0'; - + return buf; } @@ -347,7 +347,7 @@ evhttp_add_event(struct event *ev, int timeout, int default_timeout) { if (timeout != 0) { struct timeval tv; - + evutil_timerclear(&tv); tv.tv_sec = timeout != -1 ? timeout : default_timeout; event_add(ev, &tv); @@ -396,7 +396,7 @@ evhttp_make_header_request(struct evhttp_connection *evcon, struct evhttp_request *req) { const char *method; - + evhttp_remove_header(req->output_headers, "Proxy-Connection"); /* Generate request line */ @@ -432,7 +432,7 @@ static int evhttp_is_connection_keepalive(struct evkeyvalq* headers) { const char *connection = evhttp_find_header(headers, "Connection"); - return (connection != NULL + return (connection != NULL && strncasecmp(connection, "keep-alive", 10) == 0); } @@ -499,7 +499,7 @@ evhttp_make_header_response(struct evhttp_connection *evcon, if ((req->minor == 1 || is_keepalive) && evhttp_response_needs_body(req)) { - /* + /* * we need to add the content length if the * user did not give it, this is required for * persistent connections to work. @@ -533,7 +533,7 @@ evhttp_make_header(struct evhttp_connection *evcon, struct evhttp_request *req) { struct evkeyval *header; struct evbuffer *output = bufferevent_get_output(evcon->bufev); - + /* * Depending if this is a HTTP request or response, we might need to * add some new headers or remove existing headers. @@ -566,7 +566,7 @@ evhttp_connection_incoming_fail(struct evhttp_request *req, switch (error) { case EVCON_HTTP_TIMEOUT: case EVCON_HTTP_EOF: - /* + /* * these are cases in which we probably should just * close the connection and not send a reply. this * case may happen when a browser keeps a persistent @@ -583,13 +583,13 @@ evhttp_connection_incoming_fail(struct evhttp_request *req, req->uri = NULL; } - /* + /* * the callback needs to send a reply, once the reply has * been send, the connection should get freed. */ (*req->cb)(req, req->cb_arg); } - + return (0); } @@ -601,11 +601,11 @@ evhttp_connection_fail(struct evhttp_connection *evcon, void (*cb)(struct evhttp_request *, void *); void *cb_arg; assert(req != NULL); - + bufferevent_disable(evcon->bufev, EV_READ|EV_WRITE); if (evcon->flags & EVHTTP_CON_INCOMING) { - /* + /* * for incoming requests, there are two different * failure cases. it's either a network level error * or an http layer error. for problems on the network @@ -638,7 +638,7 @@ evhttp_connection_fail(struct evhttp_connection *evcon, /* reset the connection */ evhttp_connection_reset(evcon); - + /* We are trying the next request that was queued on us */ if (TAILQ_FIRST(&evcon->requests) != NULL) evhttp_connection_connect(evcon); @@ -679,7 +679,7 @@ evhttp_connection_done(struct evhttp_connection *evcon) evcon->state = EVCON_IDLE; - need_close = + need_close = evhttp_is_connection_close(req->flags, req->input_headers)|| evhttp_is_connection_close(req->flags, req->output_headers); @@ -816,7 +816,7 @@ static void evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req) { struct evbuffer *buf = bufferevent_get_input(evcon->bufev); - + if (req->chunked) { switch (evhttp_handle_chunked_read(req, buf)) { case ALL_DATA_READ: @@ -992,14 +992,14 @@ static void evhttp_request_dispatch(struct evhttp_connection* evcon) { struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); - + /* this should not usually happy but it's possible */ if (req == NULL) return; /* delete possible close detection events */ evhttp_connection_stop_detectclose(evcon); - + /* we assume that the connection is connected already */ assert(evcon->state == EVCON_IDLE); @@ -1130,7 +1130,7 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg) /* For connections from the client, we just * reset the connection so that it becomes * disconnected. - */ + */ assert(evcon->state == EVCON_IDLE); evhttp_connection_reset(evcon); return; @@ -1187,10 +1187,10 @@ evhttp_connection_cb(struct bufferevent *bufev, void *arg) evcon); if (evcon->timeout == -1) - bufferevent_settimeout(evcon->bufev, + bufferevent_settimeout(evcon->bufev, HTTP_READ_TIMEOUT, HTTP_WRITE_TIMEOUT); else - bufferevent_settimeout(evcon->bufev, + bufferevent_settimeout(evcon->bufev, evcon->timeout, evcon->timeout); /* try to start requests that have queued up on this connection */ @@ -1524,7 +1524,7 @@ evhttp_get_body_length(struct evhttp_request *req) content_length = evhttp_find_header(headers, "Content-Length"); connection = evhttp_find_header(headers, "Connection"); - + if (content_length == NULL && connection == NULL) req->ntoread = -1; else if (content_length == NULL && @@ -1546,7 +1546,7 @@ evhttp_get_body_length(struct evhttp_request *req) } req->ntoread = ntoread; } - + event_debug(("%s: bytes to read: %d (in buffer %ld)\n", __func__, req->ntoread, EVBUFFER_LENGTH(bufferevent_get_input(req->evcon->bufev)))); @@ -1558,7 +1558,7 @@ static void evhttp_get_body(struct evhttp_connection *evcon, struct evhttp_request *req) { const char *xfer_enc; - + /* If this is a request without a body, then we are done */ if (req->kind == EVHTTP_REQUEST && (req->type != EVHTTP_REQ_POST && req->type != EVHTTP_REQ_PUT)) { @@ -1676,7 +1676,7 @@ evhttp_connection_base_new(struct event_base *base, const char *address, unsigned short port) { struct evhttp_connection *evcon = NULL; - + event_debug(("Attempting connection to %s:%d\n", address, port)); if ((evcon = mm_calloc(1, sizeof(struct evhttp_connection))) == NULL) { @@ -1712,7 +1712,7 @@ evhttp_connection_base_new(struct event_base *base, } return (evcon); - + error: if (evcon != NULL) evhttp_connection_free(evcon); @@ -1736,10 +1736,10 @@ evhttp_connection_set_timeout(struct evhttp_connection *evcon, evcon->timeout = timeout_in_secs; if (evcon->timeout == -1) - bufferevent_settimeout(evcon->bufev, + bufferevent_settimeout(evcon->bufev, HTTP_READ_TIMEOUT, HTTP_WRITE_TIMEOUT); else - bufferevent_settimeout(evcon->bufev, + bufferevent_settimeout(evcon->bufev, evcon->timeout, evcon->timeout); } @@ -1771,12 +1771,12 @@ evhttp_connection_connect(struct evhttp_connection *evcon) { if (evcon->state == EVCON_CONNECTING) return (0); - + evhttp_connection_reset(evcon); assert(!(evcon->flags & EVHTTP_CON_INCOMING)); evcon->flags |= EVHTTP_CON_OUTGOING; - + evcon->fd = bind_socket( evcon->bind_address, evcon->bind_port, 0 /*reuse*/); if (evcon->fd == -1) { @@ -1794,7 +1794,7 @@ evhttp_connection_connect(struct evhttp_connection *evcon) /* Set up a callback for successful connection setup */ bufferevent_setfd(evcon->bufev, evcon->fd); - bufferevent_setcb(evcon->bufev, + bufferevent_setcb(evcon->bufev, NULL /* evhttp_read_cb */, evhttp_connection_cb, evhttp_error_cb, evcon); @@ -1804,7 +1804,7 @@ evhttp_connection_connect(struct evhttp_connection *evcon) bufferevent_enable(evcon->bufev, EV_WRITE); evcon->state = EVCON_CONNECTING; - + return (0); } @@ -1832,11 +1832,11 @@ evhttp_make_request(struct evhttp_connection *evcon, req->major = 1; req->minor = 1; } - + assert(req->evcon == NULL); req->evcon = evcon; assert(!(req->flags & EVHTTP_REQ_OWN_CONNECTION)); - + TAILQ_INSERT_TAIL(&evcon->requests, req, next); /* If the connection object is not connected; make it so */ @@ -1913,7 +1913,7 @@ evhttp_send_done(struct evhttp_connection *evcon, void *arg) if (need_close) { evhttp_connection_free(evcon); return; - } + } /* we have a persistent connection; try to accept another request. */ if (evhttp_associate_new_request_with_connection(evcon) == -1) { @@ -1962,7 +1962,7 @@ evhttp_send(struct evhttp_request *req, struct evbuffer *databuf) /* xxx: not sure if we really should expose the data buffer this way */ if (databuf != NULL) evbuffer_add_buffer(req->output_buffer, databuf); - + /* Adds headers to the response */ evhttp_make_header(evcon, req); @@ -1974,7 +1974,7 @@ evhttp_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *databuf) { evhttp_response_code(req, code, reason); - + evhttp_send(req, databuf); } @@ -2055,7 +2055,7 @@ evhttp_send_page(struct evhttp_request *req, struct evbuffer *databuf) req->major = 1; req->minor = 1; } - + if (req->kind != EVHTTP_RESPONSE) evhttp_response_code(req, 200, "OK"); @@ -2108,7 +2108,7 @@ evhttp_encode_uri(const char *uri) evbuffer_add(buf, "", 1); p = mm_strdup((char *)EVBUFFER_DATA(buf)); evbuffer_free(buf); - + return (p); } @@ -2141,17 +2141,17 @@ char * evhttp_decode_uri(const char *uri) { char *ret; - + if ((ret = mm_malloc(strlen(uri) + 1)) == NULL) event_err(1, "%s: malloc(%lu)", __func__, (unsigned long)(strlen(uri) + 1)); evhttp_decode_uri_internal(uri, strlen(uri), ret); - + return (ret); } -/* +/* * Helper function to parse out arguments in a query. * The arguments are separated by key and value. * URI should already be decoded. @@ -2236,7 +2236,7 @@ static int prefix_suffix_match(const char *pattern, const char *name, int ignorecase) { char c; - + while (1) { switch (c = *pattern++) { case '\0': @@ -2357,7 +2357,7 @@ evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port) } res = evhttp_accept_socket(http, fd); - + if (res != -1) event_debug(("Bound to port %d - Awaiting connections ... ", port)); @@ -2480,7 +2480,7 @@ evhttp_free(struct evhttp* http) if (http->vhost_pattern != NULL) mm_free(http->vhost_pattern); - + mm_free(http); } @@ -2734,7 +2734,7 @@ evhttp_get_request_connection( evcon->flags |= EVHTTP_CON_INCOMING; evcon->state = EVCON_READING_FIRSTLINE; - + evcon->fd = fd; bufferevent_setfd(evcon->bufev, fd); @@ -2752,17 +2752,17 @@ evhttp_associate_new_request_with_connection(struct evhttp_connection *evcon) req->evcon = evcon; /* the request ends up owning the connection */ req->flags |= EVHTTP_REQ_OWN_CONNECTION; - + TAILQ_INSERT_TAIL(&evcon->requests, req, next); - + req->kind = EVHTTP_REQUEST; - + if ((req->remote_host = mm_strdup(evcon->address)) == NULL) event_err(1, "%s: strdup", __func__); req->remote_port = evcon->port; evhttp_start_read(evcon); - + return (0); } @@ -2783,13 +2783,13 @@ evhttp_get_request(struct evhttp *http, evutil_socket_t fd, if (http->timeout != -1) evhttp_connection_set_timeout(evcon, http->timeout); - /* + /* * if we want to accept more than one request on a connection, * we need to know which http server it belongs to. */ evcon->http_server = http; TAILQ_INSERT_TAIL(&http->connections, evcon, next); - + if (evhttp_associate_new_request_with_connection(evcon) == -1) evhttp_connection_free(evcon); } @@ -2838,7 +2838,7 @@ name_from_addr(struct sockaddr *sa, socklen_t salen, ni_result = getnameinfo(sa, salen, ntop, sizeof(ntop), strport, sizeof(strport), NI_NUMERICHOST|NI_NUMERICSERV); - + if (ni_result != 0) { if (ni_result == EAI_SYSTEM) event_err(1, "getnameinfo failed"); @@ -2953,7 +2953,7 @@ bind_socket(const char *address, ev_uint16_t port, int reuse) /* just create an unbound socket */ if (address == NULL && port == 0) return bind_socket_ai(NULL, 0); - + aitop = make_addrinfo(address, port); if (aitop == NULL) diff --git a/include/event2/event.h b/include/event2/event.h index 0122bce2..bc4ab004 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -94,7 +94,7 @@ int event_base_dispatch(struct event_base *); /** Get the kernel event notification mechanism used by libevent. - + @param eb the event_base structure returned by event_base_new() @return a string identifying the kernel event mechanism (kqueue, epoll, etc.) */ diff --git a/include/event2/http.h b/include/event2/http.h index 97949f30..eab581a8 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -126,7 +126,7 @@ void evhttp_set_cb(struct evhttp *, const char *, /** Removes the callback for a specified URI */ int evhttp_del_cb(struct evhttp *, const char *); -/** +/** Set a callback for all requests that are not caught by specific callbacks Invokes the specified callback for all requests that do not match any of @@ -332,9 +332,9 @@ void evhttp_connection_set_closecb(struct evhttp_connection *evcon, void evhttp_connection_get_peer(struct evhttp_connection *evcon, char **address, ev_uint16_t *port); -/** +/** Make an HTTP request over the specified connection. - + The connection gets ownership of the request. @param evcon the evhttp_connection object over which to send the request @@ -350,7 +350,7 @@ int evhttp_make_request(struct evhttp_connection *evcon, /** Cancels a pending HTTP request. - + Cancels an ongoing HTTP request. The callback associated with this request is not executed and the request object is freed. If the request is currently being processed, e.g. it is ongoing, the corresponding @@ -379,7 +379,7 @@ struct evbuffer *evhttp_request_get_output_buffer(struct evhttp_request *req); /** Finds the value belonging to a header. - + @param headers the evkeyvalq object in which to find the header @param key the name of the header to find @returns a pointer to the value for the header or NULL if the header @@ -391,7 +391,7 @@ const char *evhttp_find_header(const struct evkeyvalq *headers, /** Removes a header from a list of exisiting headers. - + @param headers the evkeyvalq object from which to remove a header @param key the name of the header to remove @returns 0 if the header was removed, -1 otherwise. @@ -401,7 +401,7 @@ int evhttp_remove_header(struct evkeyvalq *headers, const char *key); /** Adds a header to a list of exisiting headers. - + @param headers the evkeyvalq object to which to add a header @param key the name of the header @param value the value belonging to the header diff --git a/include/event2/thread.h b/include/event2/thread.h index 6868c312..ebb015f8 100644 --- a/include/event2/thread.h +++ b/include/event2/thread.h @@ -28,7 +28,7 @@ #define _EVENT2_THREAD_H_ /** @file thread.h - + Functions for multi-threaded applications using libevent. When using a multi-threaded application in which multiple threads diff --git a/kqueue.c b/kqueue.c index 7aa84786..8224a091 100644 --- a/kqueue.c +++ b/kqueue.c @@ -116,7 +116,7 @@ kq_init(struct event_base *base) return (NULL); /* Initalize the kernel queue */ - + if ((kq = kqueue()) == -1) { event_warn("kqueue"); mm_free (kqueueop); @@ -145,7 +145,7 @@ kq_init(struct event_base *base) kqueueop->changes[0].ident = -1; kqueueop->changes[0].filter = EVFILT_READ; kqueueop->changes[0].flags = EV_ADD; - /* + /* * If kqueue works, then kevent will succeed, and it will * stick an error in events[0]. If kqueue is broken, then * kevent will fail. @@ -206,7 +206,7 @@ kq_insert(struct kqop *kqop, struct kevent *kev) memcpy(&kqop->changes[kqop->nchanges++], kev, sizeof(struct kevent)); event_debug(("%s: fd %d %s%s", - __func__, (int)kev->ident, + __func__, (int)kev->ident, kev->filter == EVFILT_READ ? "EVFILT_READ" : "EVFILT_WRITE", kev->flags == EV_DELETE ? " (del)" : "")); @@ -251,7 +251,7 @@ kq_dispatch(struct event_base *base, struct timeval *tv) int which = 0; if (events[i].flags & EV_ERROR) { - /* + /* * Error messages that can happen, when a delete fails. * EBADF happens when the file discriptor has been * closed, @@ -311,7 +311,7 @@ kq_add(struct event_base *base, int fd, short old, short events, void *p) kev.flags = EV_ADD; if (events & EV_ET) kev.flags |= EV_CLEAR; - + if (kq_insert(kqop, &kev) == -1) return (-1); } @@ -323,7 +323,7 @@ kq_add(struct event_base *base, int fd, short old, short events, void *p) kev.flags = EV_ADD; if (events & EV_ET) kev.flags |= EV_CLEAR; - + if (kq_insert(kqop, &kev) == -1) return (-1); } @@ -343,7 +343,7 @@ kq_del(struct event_base *base, int fd, short old, short events, void *p) kev.ident = fd; kev.filter = EVFILT_READ; kev.flags = EV_DELETE; - + if (kq_insert(kqop, &kev) == -1) return (-1); } @@ -353,7 +353,7 @@ kq_del(struct event_base *base, int fd, short old, short events, void *p) kev.ident = fd; kev.filter = EVFILT_WRITE; kev.flags = EV_DELETE; - + if (kq_insert(kqop, &kev) == -1) return (-1); } @@ -386,18 +386,18 @@ kq_sig_add(struct event_base *base, int nsignal, short old, short events, void * (void)p; assert(nsignal >= 0 && nsignal < NSIG); - + memset(&kev, 0, sizeof(kev)); kev.ident = nsignal; kev.filter = EVFILT_SIGNAL; kev.flags = EV_ADD; - + /* Be ready for the signal if it is sent any * time between now and the next call to * kq_dispatch. */ if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1) return (-1); - + if (_evsig_set_handler(base, nsignal, kq_sighandler) == -1) return (-1); @@ -419,7 +419,7 @@ kq_sig_del(struct event_base *base, int nsignal, short old, short events, void * kev.ident = nsignal; kev.filter = EVFILT_SIGNAL; kev.flags = EV_DELETE; - + /* Because we insert signal events * immediately, we need to delete them * immediately, too */ diff --git a/log.c b/log.c index efcce762..793ea5c2 100644 --- a/log.c +++ b/log.c @@ -70,7 +70,7 @@ void event_err(int eval, const char *fmt, ...) { va_list ap; - + va_start(ap, fmt); _warn_helper(_EVENT_LOG_ERR, strerror(errno), fmt, ap); va_end(ap); @@ -81,7 +81,7 @@ void event_warn(const char *fmt, ...) { va_list ap; - + va_start(ap, fmt); _warn_helper(_EVENT_LOG_WARN, strerror(errno), fmt, ap); va_end(ap); @@ -114,7 +114,7 @@ void event_errx(int eval, const char *fmt, ...) { va_list ap; - + va_start(ap, fmt); _warn_helper(_EVENT_LOG_ERR, NULL, fmt, ap); va_end(ap); @@ -125,7 +125,7 @@ void event_warnx(const char *fmt, ...) { va_list ap; - + va_start(ap, fmt); _warn_helper(_EVENT_LOG_WARN, NULL, fmt, ap); va_end(ap); @@ -135,7 +135,7 @@ void event_msgx(const char *fmt, ...) { va_list ap; - + va_start(ap, fmt); _warn_helper(_EVENT_LOG_MSG, NULL, fmt, ap); va_end(ap); @@ -145,7 +145,7 @@ void _event_debugx(const char *fmt, ...) { va_list ap; - + va_start(ap, fmt); _warn_helper(_EVENT_LOG_DEBUG, NULL, fmt, ap); va_end(ap); diff --git a/sample/event-test.c b/sample/event-test.c index 2c6cb938..b4276aa9 100644 --- a/sample/event-test.c +++ b/sample/event-test.c @@ -42,7 +42,7 @@ fifo_read(int fd, short event, void *arg) #ifdef WIN32 len = ReadFile((HANDLE)fd, buf, sizeof(buf) - 1, &dwBytesRead, NULL); - // Check for end of file. + // Check for end of file. if(len && dwBytesRead == 0) { fprintf(stderr, "End Of File"); event_del(ev); @@ -72,14 +72,14 @@ main (int argc, char **argv) struct event evfifo; #ifdef WIN32 HANDLE socket; - // Open a file. - socket = CreateFile("test.txt", // open File - GENERIC_READ, // open for reading - 0, // do not share - NULL, // no security - OPEN_EXISTING, // existing file only - FILE_ATTRIBUTE_NORMAL, // normal file - NULL); // no attr. template + // Open a file. + socket = CreateFile("test.txt", // open File + GENERIC_READ, // open for reading + 0, // do not share + NULL, // no security + OPEN_EXISTING, // existing file only + FILE_ATTRIBUTE_NORMAL, // normal file + NULL); // no attr. template if(socket == INVALID_HANDLE_VALUE) return 1; @@ -88,7 +88,7 @@ main (int argc, char **argv) struct stat st; const char *fifo = "event.fifo"; int socket; - + if (lstat (fifo, &st) == 0) { if ((st.st_mode & S_IFMT) == S_IFREG) { errno = EEXIST; @@ -129,7 +129,7 @@ main (int argc, char **argv) /* Add it to the active events, without a timeout */ event_add(&evfifo, NULL); - + event_dispatch(); #ifdef WIN32 CloseHandle(socket); diff --git a/sample/signal-test.c b/sample/signal-test.c index 9a131cb5..cb464834 100644 --- a/sample/signal-test.c +++ b/sample/signal-test.c @@ -38,7 +38,7 @@ signal_cb(int fd, short event, void *arg) if (called >= 2) event_del(signal); - + called++; } @@ -46,7 +46,7 @@ int main (int argc, char **argv) { struct event signal_int; - + /* Initalize the event library */ event_init(); diff --git a/sample/time-test.c b/sample/time-test.c index 069d4f8f..faf0999d 100644 --- a/sample/time-test.c +++ b/sample/time-test.c @@ -50,7 +50,7 @@ main (int argc, char **argv) { struct event timeout; struct timeval tv; - + /* Initalize the event library */ event_init(); @@ -62,7 +62,7 @@ main (int argc, char **argv) event_add(&timeout, &tv); lasttime = time(NULL); - + event_dispatch(); return (0); diff --git a/signal.c b/signal.c index 5388ca84..30c5e026 100644 --- a/signal.c +++ b/signal.c @@ -111,7 +111,7 @@ evsig_cb(evutil_socket_t fd, short what, void *arg) void evsig_init(struct event_base *base) { - /* + /* * Our signal handler is going to write to one end of the socket * pair to wake up our event loop. The event loop then scans for * signals that got delivered. @@ -305,7 +305,7 @@ evsig_process(struct event_base *base) struct evsig_info *sig = &base->sig; sig_atomic_t ncalls; int i; - + base->sig.evsig_caught = 0; for (i = 1; i < NSIG; ++i) { ncalls = sig->evsigcaught[i]; diff --git a/test/regress.c b/test/regress.c index 61c92d29..6fbc32ae 100644 --- a/test/regress.c +++ b/test/regress.c @@ -178,7 +178,7 @@ multiple_read_cb(int fd, short event, void *arg) roff += len; if (!usepersist) { - if (event_add(ev, NULL) == -1) + if (event_add(ev, NULL) == -1) exit(1); } } @@ -301,7 +301,7 @@ test_simpleread(void) /* Very simple read test */ setup_test("Simple read: "); - + write(pair[0], TEST1, strlen(TEST1)+1); shutdown(pair[0], SHUT_WR); @@ -320,7 +320,7 @@ test_simplewrite(void) /* Very simple write test */ setup_test("Simple write: "); - + event_set(&ev, pair[0], EV_WRITE, simple_write_cb, &ev); if (event_add(&ev, NULL) == -1) exit(1); @@ -343,7 +343,7 @@ test_simpleread_multiple(void) /* Very simple read test */ setup_test("Simple read to multiple evens: "); - + write(pair[0], TEST1, strlen(TEST1)+1); shutdown(pair[0], SHUT_WR); @@ -558,7 +558,7 @@ test_fork(void) event_base_free(current_base); - /* we do not send an EOF; simple_read_cb requires an EOF + /* we do not send an EOF; simple_read_cb requires an EOF * to set test_ok. we just verify that the callback was * called. */ exit(test_ok != 0 || called != 2 ? -2 : 76); @@ -573,7 +573,7 @@ test_fork(void) fprintf(stdout, "FAILED (fork)\n"); exit(1); } - + if (WEXITSTATUS(status) != 76) { fprintf(stdout, "FAILED (exit): %d\n", WEXITSTATUS(status)); exit(1); @@ -967,7 +967,7 @@ test_loopexit_multiple(void) setup_test("Loop Multiple exit: "); base = event_base_new(); - + tv.tv_usec = 0; tv.tv_sec = 1; event_base_loopexit(base, &tv); @@ -979,7 +979,7 @@ test_loopexit_multiple(void) event_base_dispatch(base); event_base_free(base); - + test_ok = 1; cleanup_test(); @@ -1083,7 +1083,7 @@ evbuffer_validate(struct evbuffer *buf) { struct evbuffer_chain *chain, *previous = NULL; size_t sum = 0; - + if (buf->first == NULL) { assert(buf->last == NULL); assert(buf->previous_to_last == NULL); @@ -1227,9 +1227,9 @@ test_evbuffer(void) evbuffer_validate(evb); } } - + test_ok = 1; - + out: evbuffer_free(evb); evbuffer_free(evb_two); @@ -1452,7 +1452,7 @@ test_evbuffer_iterative(void) sum += j; } } - + if (sum == EVBUFFER_LENGTH(buf)) test_ok = 1; @@ -1476,7 +1476,7 @@ test_evbuffer_find(void) fprintf(stdout, "Testing evbuffer_find 1: "); evbuffer_add(buf, (u_char*)test1, strlen(test1)); evbuffer_validate(buf); - evbuffer_drain(buf, strlen(test1)); + evbuffer_drain(buf, strlen(test1)); evbuffer_validate(buf); evbuffer_add(buf, (u_char*)test2, strlen(test2)); evbuffer_validate(buf); @@ -1852,7 +1852,7 @@ test_multiple_events_for_same_fd(void) write(pair[1], TEST1, strlen(TEST1)+1); event_loop(EVLOOP_ONCE); event_del(&e1); - + if (test_ok != 3) test_ok = 0; @@ -1890,14 +1890,14 @@ test_want_only_once(void) /* Very simple read test */ setup_test("Want read only once: "); - + write(pair[0], TEST1, strlen(TEST1)+1); /* Setup the loop termination */ evutil_timerclear(&tv); tv.tv_sec = 1; event_loopexit(&tv); - + event_set(&ev, pair[1], EV_READ, read_once_cb, &ev); if (event_add(&ev, NULL) == -1) exit(1); @@ -2174,7 +2174,7 @@ rpc_test(void) fprintf(stderr, "Incorrect note strings encoded.\n"); exit(1); } - + if (EVTAG_GET(run, large_number, &large_number) == -1 || large_number != 0xdead0a0bcafebeefLL) { fprintf(stderr, "Incorrrect large_number.\n"); @@ -2437,7 +2437,7 @@ main (int argc, char **argv) test_signal_assert(); test_signal_while_processing(); #endif - + return (0); } diff --git a/test/regress_http.c b/test/regress_http.c index 17c7a026..889c852e 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -129,7 +129,7 @@ http_connect(const char *address, u_short port) struct sockaddr *sa; int slen; int fd; - + #ifdef WIN32 if (!(he = gethostbyname(address))) { event_warn("gethostbyname"); @@ -151,7 +151,7 @@ http_connect(const char *address, u_short port) sa = aitop->ai_addr; slen = aitop->ai_addrlen; #endif - + fd = socket(AF_INET, SOCK_STREAM, 0); if (fd == -1) event_err(1, "socket failed"); @@ -182,7 +182,7 @@ http_readcb(struct bufferevent *bev, void *arg) const char *what = BASIC_REQUEST_BODY; event_debug(("%s: %s\n", __func__, EVBUFFER_DATA(EVBUFFER_INPUT(bev)))); - + if (evbuffer_find(EVBUFFER_INPUT(bev), (const unsigned char*) what, strlen(what)) != NULL) { struct evhttp_request *req = evhttp_request_new(NULL, NULL); @@ -236,7 +236,7 @@ http_basic_cb(struct evhttp_request *req, void *arg) int empty = evhttp_find_header(req->input_headers, "Empty") != NULL; event_debug(("%s: called\n", __func__)); evbuffer_add_printf(evb, BASIC_REQUEST_BODY); - + /* For multi-line headers test */ { const char *multi = @@ -305,7 +305,7 @@ http_chunked_cb(struct evhttp_request *req, void *arg) if (strcmp(evhttp_request_uri(req), "/streamed") == 0) { evhttp_add_header(req->output_headers, "Content-Length", "39"); } - + /* generate a chunked/streamed reply */ evhttp_send_reply_start(req, HTTP_OK, "Everything is fine"); @@ -343,7 +343,7 @@ http_basic_test(void) fprintf(stdout, "FAILED (bind)\n"); exit(1); } - + fd = http_connect("127.0.0.1", port); /* Stupid thing to send a request */ @@ -359,7 +359,7 @@ http_basic_test(void) timerclear(&tv); tv.tv_usec = 10000; event_once(-1, EV_TIMEOUT, http_complete_write, bev, &tv); - + event_dispatch(); if (test_ok != 3) { @@ -384,14 +384,14 @@ http_basic_test(void) "\r\n"; bufferevent_write(bev, http_request, strlen(http_request)); - + event_dispatch(); bufferevent_free(bev); EVUTIL_CLOSESOCKET(fd); evhttp_free(http); - + if (test_ok != 5) { fprintf(stdout, "FAILED\n"); exit(1); @@ -472,7 +472,7 @@ http_delete_test(void) fprintf(stdout, "Testing HTTP DELETE Request: "); http = http_setup(&port, NULL); - + fd = http_connect("127.0.0.1", port); /* Stupid thing to send a request */ @@ -486,19 +486,19 @@ http_delete_test(void) "\r\n"; bufferevent_write(bev, http_request, strlen(http_request)); - + event_dispatch(); bufferevent_free(bev); EVUTIL_CLOSESOCKET(fd); evhttp_free(http); - + if (test_ok != 2) { fprintf(stdout, "FAILED\n"); exit(1); } - + fprintf(stdout, "OK\n"); } @@ -511,7 +511,7 @@ http_connection_test(int persistent) short port = -1; struct evhttp_connection *evcon = NULL; struct evhttp_request *req = NULL; - + test_ok = 0; fprintf(stdout, "Testing Request Connection Pipeline %s: ", persistent ? "(persistent)" : ""); @@ -549,13 +549,13 @@ http_connection_test(int persistent) /* try to make another request over the same connection */ test_ok = 0; - + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); /* Add the information that we care about */ evhttp_add_header(req->output_headers, "Host", "somehost"); - /* + /* * if our connections are not supposed to be persistent; request * a close from the server. */ @@ -572,7 +572,7 @@ http_connection_test(int persistent) /* make another request: request empty reply */ test_ok = 0; - + req = evhttp_request_new(http_request_empty_done, NULL); /* Add the information that we care about */ @@ -593,7 +593,7 @@ http_connection_test(int persistent) evhttp_connection_free(evcon); evhttp_free(http); - + fprintf(stdout, "OK\n"); } @@ -627,7 +627,7 @@ http_cancel_test(void) struct evhttp_connection *evcon = NULL; struct evhttp_request *req = NULL; struct timeval tv; - + test_ok = 0; fprintf(stdout, "Testing Request Cancelation: "); @@ -670,7 +670,7 @@ http_cancel_test(void) /* try to make another request over the same connection */ test_ok = 0; - + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); /* Add the information that we care about */ @@ -686,7 +686,7 @@ http_cancel_test(void) /* make another request: request empty reply */ test_ok = 0; - + req = evhttp_request_new(http_request_empty_done, NULL); /* Add the information that we care about */ @@ -707,7 +707,7 @@ http_cancel_test(void) evhttp_connection_free(evcon); evhttp_free(http); - + fprintf(stdout, "OK\n"); } @@ -730,7 +730,7 @@ http_request_done(struct evhttp_request *req, void *arg) fprintf(stderr, "FAILED\n"); exit(1); } - + if (memcmp(EVBUFFER_DATA(req->input_buffer), what, strlen(what)) != 0) { fprintf(stderr, "FAILED\n"); exit(1); @@ -760,7 +760,7 @@ http_virtual_host_test(void) struct evhttp_connection *evcon = NULL; struct evhttp_request *req = NULL; struct evhttp *second = NULL, *third = NULL; - + test_ok = 0; fprintf(stdout, "Testing Virtual Hosts: "); @@ -854,7 +854,7 @@ http_virtual_host_test(void) evhttp_connection_free(evcon); evhttp_free(http); - + fprintf(stdout, "OK\n"); } @@ -874,7 +874,7 @@ http_request_empty_done(struct evhttp_request *req, void *arg) exit(1); } - + if (evhttp_find_header(req->input_headers, "Content-Length") == NULL) { fprintf(stderr, "FAILED\n"); exit(1); @@ -932,7 +932,7 @@ http_dispatcher_test_done(struct evhttp_request *req, void *arg) EVBUFFER_LENGTH(req->input_buffer), strlen(what)); exit(1); } - + if (memcmp(EVBUFFER_DATA(req->input_buffer), what, strlen(what)) != 0) { fprintf(stderr, "FAILED (data)\n"); exit(1); @@ -976,7 +976,7 @@ http_dispatcher_test(void) /* Add the information that we care about */ evhttp_add_header(req->output_headers, "Host", "somehost"); - + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/?arg=val") == -1) { fprintf(stdout, "FAILED\n"); exit(1); @@ -986,12 +986,12 @@ http_dispatcher_test(void) evhttp_connection_free(evcon); evhttp_free(http); - + if (test_ok != 1) { fprintf(stdout, "FAILED: %d\n", test_ok); exit(1); } - + fprintf(stdout, "OK\n"); } @@ -1035,7 +1035,7 @@ http_post_test(void) /* Add the information that we care about */ evhttp_add_header(req->output_headers, "Host", "somehost"); evbuffer_add_printf(req->output_buffer, POST_DATA); - + if (evhttp_make_request(evcon, req, EVHTTP_REQ_POST, "/postit") == -1) { fprintf(stdout, "FAILED\n"); exit(1); @@ -1045,12 +1045,12 @@ http_post_test(void) evhttp_connection_free(evcon); evhttp_free(http); - + if (test_ok != 1) { fprintf(stdout, "FAILED: %d\n", test_ok); exit(1); } - + fprintf(stdout, "OK\n"); } @@ -1079,7 +1079,7 @@ http_post_cb(struct evhttp_request *req, void *arg) fprintf(stdout, "Want:%s\n", POST_DATA); exit(1); } - + evb = evbuffer_new(); evbuffer_add_printf(evb, BASIC_REQUEST_BODY); @@ -1099,7 +1099,7 @@ http_postrequest_done(struct evhttp_request *req, void *arg) } if (req->response_code != HTTP_OK) { - + fprintf(stderr, "FAILED (response code)\n"); exit(1); } @@ -1114,7 +1114,7 @@ http_postrequest_done(struct evhttp_request *req, void *arg) EVBUFFER_LENGTH(req->input_buffer), strlen(what)); exit(1); } - + if (memcmp(EVBUFFER_DATA(req->input_buffer), what, strlen(what)) != 0) { fprintf(stderr, "FAILED (data)\n"); exit(1); @@ -1163,7 +1163,7 @@ http_put_test(void) /* Add the information that we care about */ evhttp_add_header(req->output_headers, "Host", "someotherhost"); evbuffer_add_printf(req->output_buffer, PUT_DATA); - + if (evhttp_make_request(evcon, req, EVHTTP_REQ_PUT, "/putit") == -1) { fprintf(stdout, "FAILED\n"); exit(1); @@ -1173,12 +1173,12 @@ http_put_test(void) evhttp_connection_free(evcon); evhttp_free(http); - + if (test_ok != 1) { fprintf(stdout, "FAILED: %d\n", test_ok); exit(1); } - + fprintf(stdout, "OK\n"); } @@ -1207,7 +1207,7 @@ http_put_cb(struct evhttp_request *req, void *arg) fprintf(stdout, "Want:%s\n", PUT_DATA); exit(1); } - + evb = evbuffer_new(); evbuffer_add_printf(evb, "That ain't funny"); @@ -1227,7 +1227,7 @@ http_putrequest_done(struct evhttp_request *req, void *arg) } if (req->response_code != HTTP_OK) { - + fprintf(stderr, "FAILED (response code)\n"); exit(1); } @@ -1242,7 +1242,7 @@ http_putrequest_done(struct evhttp_request *req, void *arg) EVBUFFER_LENGTH(req->input_buffer), strlen(what)); exit(1); } - + if (memcmp(EVBUFFER_DATA(req->input_buffer), what, strlen(what)) != 0) { fprintf(stderr, "FAILED (data)\n"); exit(1); @@ -1279,7 +1279,7 @@ http_failure_test(void) fprintf(stdout, "Testing Bad HTTP Request: "); http = http_setup(&port, NULL); - + fd = http_connect("127.0.0.1", port); /* Stupid thing to send a request */ @@ -1289,19 +1289,19 @@ http_failure_test(void) http_request = "illegal request\r\n"; bufferevent_write(bev, http_request, strlen(http_request)); - + event_dispatch(); bufferevent_free(bev); EVUTIL_CLOSESOCKET(fd); evhttp_free(http); - + if (test_ok != 2) { fprintf(stdout, "FAILED\n"); exit(1); } - + fprintf(stdout, "OK\n"); } @@ -1346,7 +1346,7 @@ close_detect_cb(struct evhttp_request *req, void *arg) struct timeval tv; if (req != NULL && req->response_code != HTTP_OK) { - + fprintf(stderr, "FAILED\n"); exit(1); } @@ -1365,7 +1365,7 @@ http_close_detection(int with_delay) short port = -1; struct evhttp_connection *evcon = NULL; struct evhttp_request *req = NULL; - + test_ok = 0; fprintf(stdout, "Testing Connection Close Detection%s: ", with_delay ? " (with delay)" : ""); @@ -1415,7 +1415,7 @@ http_close_detection(int with_delay) evhttp_connection_free(evcon); evhttp_free(http); - + fprintf(stdout, "OK\n"); } @@ -1424,7 +1424,7 @@ http_highport_test(void) { int i = -1; struct evhttp *myhttp = NULL; - + fprintf(stdout, "Testing HTTP Server with high port: "); /* Try a few different ports */ @@ -1452,7 +1452,7 @@ http_bad_header_test(void) if (evhttp_add_header(&headers, "One", "Two") != 0) goto fail; - + if (evhttp_add_header(&headers, "One\r", "Two") != -1) goto fail; @@ -1488,14 +1488,14 @@ http_base_test(void) base = event_init(); - /* + /* * create another bogus base - which is being used by all subsequen * tests - yuck! */ tmp = event_init(); http = http_setup(&port, base); - + fd = http_connect("127.0.0.1", port); /* Stupid thing to send a request */ @@ -1510,7 +1510,7 @@ http_base_test(void) "\r\n"; bufferevent_write(bev, http_request, strlen(http_request)); - + event_base_dispatch(base); bufferevent_free(bev); @@ -1520,12 +1520,12 @@ http_base_test(void) event_base_free(base); base = tmp; - + if (test_ok != 2) { fprintf(stdout, "FAILED\n"); exit(1); } - + fprintf(stdout, "OK\n"); } @@ -1588,7 +1588,7 @@ http_incomplete_test(int use_timeout) fd = http_connect("127.0.0.1", port); /* Stupid thing to send a request */ - bev = bufferevent_new(fd, + bev = bufferevent_new(fd, http_incomplete_readcb, http_incomplete_writecb, http_incomplete_errorcb, use_timeout ? NULL : &fd); @@ -1599,7 +1599,7 @@ http_incomplete_test(int use_timeout) bufferevent_write(bev, http_request, strlen(http_request)); evutil_gettimeofday(&tv_start, NULL); - + event_dispatch(); evutil_gettimeofday(&tv_end, NULL); @@ -1626,7 +1626,7 @@ http_incomplete_test(int use_timeout) fprintf(stdout, "FAILED\n"); exit(1); } - + fprintf(stdout, "OK\n"); } @@ -1652,7 +1652,7 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg) struct evhttp_request *req = evhttp_request_new(NULL, NULL); const char *header; enum message_read_status done; - + req->kind = EVHTTP_RESPONSE; done = evhttp_parse_firstline(req, EVBUFFER_INPUT(bev)); if (done != ALL_DATA_READ) @@ -1764,7 +1764,7 @@ http_chunked_request_done(struct evhttp_request *req, void *arg) fprintf(stderr, "FAILED\n"); exit(1); } - + test_ok = 1; event_loopexit(NULL); } @@ -1789,7 +1789,7 @@ http_chunk_out_test(void) fd = http_connect("127.0.0.1", port); /* Stupid thing to send a request */ - bev = bufferevent_new(fd, + bev = bufferevent_new(fd, http_chunked_readcb, http_chunked_writecb, http_chunked_errorcb, NULL); @@ -1802,7 +1802,7 @@ http_chunk_out_test(void) bufferevent_write(bev, http_request, strlen(http_request)); evutil_gettimeofday(&tv_start, NULL); - + event_dispatch(); bufferevent_free(bev); @@ -1853,7 +1853,7 @@ http_chunk_out_test(void) evhttp_connection_free(evcon); evhttp_free(http); - + fprintf(stdout, "OK\n"); } @@ -1863,7 +1863,7 @@ http_stream_out_test(void) short port = -1; struct evhttp_connection *evcon = NULL; struct evhttp_request *req = NULL; - + test_ok = 0; printf("Tests streaming responses out: "); @@ -1902,7 +1902,7 @@ http_stream_out_test(void) evhttp_connection_free(evcon); evhttp_free(http); - + fprintf(stdout, "OK\n"); } @@ -2051,7 +2051,7 @@ http_connection_retry_done(struct evhttp_request *req, void *arg) fprintf(stderr, "FAILED (connection aborted)\n"); exit(1); } - + if (req->response_code == HTTP_OK) { fprintf(stderr, "FAILED\n"); exit(1); @@ -2066,7 +2066,7 @@ http_connection_retry_done(struct evhttp_request *req, void *arg) fprintf(stderr, "FAILED (length)\n"); exit(1); } - + test_ok = 1; event_loopexit(NULL); } @@ -2116,7 +2116,7 @@ http_connection_retry(void) /* Add the information that we care about */ evhttp_add_header(req->output_headers, "Host", "somehost"); - + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/?arg=val") == -1) { fprintf(stdout, "FAILED\n"); @@ -2153,7 +2153,7 @@ http_connection_retry(void) /* Add the information that we care about */ evhttp_add_header(req->output_headers, "Host", "somehost"); - + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/?arg=val") == -1) { fprintf(stdout, "FAILED\n"); @@ -2191,7 +2191,7 @@ http_connection_retry(void) /* Add the information that we care about */ evhttp_add_header(req->output_headers, "Host", "somehost"); - + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/?arg=val") == -1) { fprintf(stdout, "FAILED\n"); @@ -2222,7 +2222,7 @@ http_connection_retry(void) evhttp_connection_free(evcon); evhttp_free(http); - + fprintf(stdout, "OK\n"); } @@ -2258,12 +2258,12 @@ http_multi_line_header_test(void) int fd; const char *http_start_request; short port = -1; - + test_ok = 0; fprintf(stdout, "Testing HTTP Server with multi line: "); http = http_setup(&port, NULL); - + fd = http_connect("127.0.0.1", port); /* Stupid thing to send a request */ @@ -2279,11 +2279,11 @@ http_multi_line_header_test(void) "\tEND\r\n" "X-Last: last\r\n" "\r\n"; - + bufferevent_write(bev, http_start_request, strlen(http_start_request)); event_dispatch(); - + bufferevent_free(bev); close(fd); @@ -2293,7 +2293,7 @@ http_multi_line_header_test(void) fprintf(stdout, "FAILED\n"); exit(1); } - + fprintf(stdout, "OK\n"); } @@ -2315,7 +2315,7 @@ http_negative_content_length_test(void) short port = -1; struct evhttp_connection *evcon = NULL; struct evhttp_request *req = NULL; - + test_ok = 0; fprintf(stdout, "Testing HTTP Negative Content Length: "); diff --git a/test/regress_rpc.c b/test/regress_rpc.c index 79f8b6c2..ac4bdbc7 100644 --- a/test/regress_rpc.c +++ b/test/regress_rpc.c @@ -134,7 +134,7 @@ rpc_setup(struct evhttp **phttp, short *pport, struct evrpc_base **pbase) http = http_setup(&port); base = evrpc_init(http); - + EVRPC_REGISTER(base, Message, msg, kill, MessageCb, NULL); EVRPC_REGISTER(base, NeverReply, msg, kill, NeverReplyCb, NULL); @@ -159,7 +159,7 @@ static void rpc_postrequest_failure(struct evhttp_request *req, void *arg) { if (req->response_code != HTTP_SERVUNAVAIL) { - + fprintf(stderr, "FAILED (response code)\n"); exit(1); } @@ -205,7 +205,7 @@ rpc_basic_test(void) /* Add the information that we care about */ evhttp_add_header(req->output_headers, "Host", "somehost"); evbuffer_add_printf(req->output_buffer, "Some Nonsense"); - + if (evhttp_make_request(evcon, req, EVHTTP_REQ_POST, "/.rpc.Message") == -1) { @@ -220,7 +220,7 @@ rpc_basic_test(void) evhttp_connection_free(evcon); rpc_teardown(base); - + if (test_ok != 1) { fprintf(stdout, "FAILED\n"); exit(1); @@ -237,7 +237,7 @@ rpc_postrequest_done(struct evhttp_request *req, void *arg) struct kill* kill_reply = NULL; if (req->response_code != HTTP_OK) { - + fprintf(stderr, "FAILED (response code)\n"); exit(1); } @@ -248,7 +248,7 @@ rpc_postrequest_done(struct evhttp_request *req, void *arg) fprintf(stderr, "FAILED (unmarshal)\n"); exit(1); } - + kill_free(kill_reply); test_ok = 1; @@ -308,9 +308,9 @@ rpc_basic_message(void) event_dispatch(); evhttp_connection_free(evcon); - + rpc_teardown(base); - + if (test_ok != 1) { fprintf(stdout, "FAILED\n"); exit(1); @@ -334,7 +334,7 @@ rpc_pool_with_connection(short port) assert(evcon != NULL); evrpc_pool_add_connection(pool, evcon); - + return (pool); } @@ -415,7 +415,7 @@ rpc_hook_add_header(void *ctx, struct evhttp_request *req, const char *hook_type = arg; if (strcmp("input", hook_type) == 0) evhttp_add_header(req->input_headers, "X-Hook", hook_type); - else + else evhttp_add_header(req->output_headers, "X-Hook", hook_type); assert(evrpc_hook_get_connection(ctx) != NULL); @@ -496,7 +496,7 @@ rpc_basic_client(void) test_ok = 0; event_dispatch(); - + if (test_ok != 1) { fprintf(stdout, "FAILED (1)\n"); exit(1); @@ -508,7 +508,7 @@ rpc_basic_client(void) EVRPC_MAKE_REQUEST(Message, pool, msg, kill, GotKillCb, NULL); event_dispatch(); - + if (test_ok != 2) { fprintf(stdout, "FAILED (2)\n"); exit(1); @@ -526,9 +526,9 @@ rpc_basic_client(void) } event_dispatch(); - + rpc_teardown(base); - + if (test_ok != 3) { fprintf(stdout, "FAILED (3)\n"); exit(1); @@ -546,7 +546,7 @@ rpc_basic_client(void) need_output_hook = 0; } -/* +/* * We are testing that the second requests gets send over the same * connection after the first RPCs completes. */ @@ -580,9 +580,9 @@ rpc_basic_queued_client(void) test_ok = 0; event_dispatch(); - + rpc_teardown(base); - + if (test_ok != 2) { fprintf(stdout, "FAILED (1)\n"); exit(1); @@ -682,14 +682,14 @@ rpc_basic_client_with_pause(void) test_ok = 0; event_dispatch(); - + if (test_ok != 1 || hook_pause_cb_called != 4) { fprintf(stdout, "FAILED\n"); exit(1); } rpc_teardown(base); - + fprintf(stdout, "OK\n"); msg_free(msg); @@ -730,12 +730,12 @@ rpc_client_timeout(void) test_ok = 0; event_dispatch(); - + /* free the saved RPC structure up */ EVRPC_REQUEST_DONE(saved_rpc); rpc_teardown(base); - + if (test_ok != 2) { fprintf(stdout, "FAILED (1)\n"); exit(1); diff --git a/test/test-eof.c b/test/test-eof.c index 4fc1a19f..9577ed5d 100644 --- a/test/test-eof.c +++ b/test/test-eof.c @@ -63,7 +63,7 @@ main (int argc, char **argv) if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) return (1); - + write(pair[0], test, strlen(test)+1); shutdown(pair[0], SHUT_WR);