Skip to content

Commit

Permalink
fixes to make it run w/ tls
Browse files Browse the repository at this point in the history
  • Loading branch information
sd committed Dec 30, 2009
1 parent 1702145 commit b87a4a6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Makefile
@@ -1,5 +1,5 @@
#based on the makefiles in rubinius

DEV=1
# Set this such that $(LIBEVDIR)/lib include libev.so and
# $(LIBEVDIR)/include has ev.h
LIBEVDIR=$(HOME)/local/libev
Expand Down Expand Up @@ -94,9 +94,11 @@ SOURCES=ebb.c ebb_request_parser.c rbtree.c
OBJS=$(SOURCES:.c=.o)

%.o: %.c
echo $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@
$(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@

%.o: %.S
echo $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@
$(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@

.%.d: %.c $(DEPS)
Expand Down
12 changes: 6 additions & 6 deletions ebb.c
Expand Up @@ -208,7 +208,7 @@ on_handshake(struct ev_loop *loop ,ev_io *watcher, int revents)
if(r == GNUTLS_E_INTERRUPTED || r == GNUTLS_E_AGAIN)
ev_io_set( watcher
, connection->fd
, EV_ERROR | (GNUTLS_NEED_WRITE ? EV_WRITE : EV_READ)
, (GNUTLS_NEED_WRITE ? EV_WRITE : EV_READ)
);
return;
}
Expand Down Expand Up @@ -422,7 +422,7 @@ on_goodbye_tls(struct ev_loop *loop, ev_io *watcher, int revents)
if(r == GNUTLS_E_INTERRUPTED || r == GNUTLS_E_AGAIN)
ev_io_set( watcher
, connection->fd
, EV_ERROR | (GNUTLS_NEED_WRITE ? EV_WRITE : EV_READ)
, (GNUTLS_NEED_WRITE ? EV_WRITE : EV_READ)
);
return;
}
Expand Down Expand Up @@ -455,7 +455,7 @@ static void conn_setup(struct ev_loop *loop, ebb_connection *connection)
ev_timer_start(loop, &connection->timeout_watcher);

#ifdef HAVE_GNUTLS
if(server->secure) {
if(connection->secure) {
ev_io_start(loop, &connection->handshake_watcher);
return;
}
Expand Down Expand Up @@ -535,7 +535,7 @@ on_connection(struct ev_loop *loop, ev_io *watcher, int revents)
gnutls_db_set_remove_function (connection->session, session_cache_remove);
}

ev_io_set(&connection->handshake_watcher, connection->fd, EV_READ | EV_WRITE | EV_ERROR);
ev_io_set(&connection->handshake_watcher, connection->fd, EV_READ | EV_WRITE);
#endif /* HAVE_GNUTLS */

conn_setup(loop, connection);
Expand All @@ -560,7 +560,7 @@ ebb_server_listen_on_fd(ebb_server *server, const int fd)
server->fd = fd;
server->listening = TRUE;

ev_io_set (&server->connection_watcher, server->fd, EV_READ | EV_ERROR);
ev_io_set (&server->connection_watcher, server->fd, EV_READ);
ev_io_start (server->loop, &server->connection_watcher);

return server->fd;
Expand Down Expand Up @@ -805,7 +805,7 @@ ebb_connection_schedule_close (ebb_connection *connection)
{
#ifdef HAVE_GNUTLS
if(connection->secure) {
ev_io_set(&connection->goodbye_tls_watcher, connection->fd, EV_ERROR | EV_READ | EV_WRITE);
ev_io_set(&connection->goodbye_tls_watcher, connection->fd, EV_READ | EV_WRITE);
ev_io_start(connection->loop, &connection->goodbye_tls_watcher);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion ebb.h
Expand Up @@ -92,7 +92,7 @@ struct ebb_connection {

/* Public */

ebb_request* (*new_request) (ebb_connection*);
// ebb_request* (*new_request) (ebb_connection*);

/* The new_buf callback allocates and initializes an ebb_buf structure.
* By default this is set to a simple malloc() based callback which always
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world.c
Expand Up @@ -89,7 +89,7 @@ int main()
ebb_server server;

ebb_server_init(&server, loop);
//ebb_server_set_secure(&server, "examples/ca-cert.pem", "examples/ca-key.pem");
ebb_server_set_secure(&server, "ca-cert.pem", "ca-key.pem");
server.new_connection = new_connection;

printf("hello_world listening on port 5000\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/redir.c
Expand Up @@ -83,13 +83,14 @@ ebb_connection *new_connection(ebb_server *server, struct sockaddr_in *addr)
int main(int argc, char *argv[])
{
struct ev_loop *loop = ev_default_loop(0);
ebb_server server;
static ebb_server server;

assert(argc == 4 && "Expected 3 arguments: listenport fwdhost fwdport");

ebb_server_init(&server, loop);
server.new_connection = new_connection;
server.data = argv+2;
ebb_server_set_secure(&server, "ca-cert.pem", "ca-key.pem");
ebb_tcp_server(&server, NULL, atol(argv[1]));

ev_loop(loop, 0);
Expand Down

0 comments on commit b87a4a6

Please sign in to comment.