merge

Tue, 10 Nov 2015 21:18:51 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 10 Nov 2015 21:18:51 +0100
changeset 112
b962d83124bc
parent 110
43a746e905f6 (current diff)
parent 111
c93be34fde76 (diff)
child 113
57e706fed20a

merge

src/server/util/io.c file | annotate | diff | comparison | revisions
src/server/util/io.h file | annotate | diff | comparison | revisions
--- a/src/server/daemon/event_bsd.c	Tue Nov 10 21:11:06 2015 +0100
+++ b/src/server/daemon/event_bsd.c	Tue Nov 10 21:18:51 2015 +0100
@@ -101,7 +101,7 @@
         }
         
         for(int i=0;i<nev;i++) {
-            event_t *event = events[i].udata;
+            event_t *event = (event_t*)events[i].udata;
             if(event->fn) {
                 if(event->fn(ev, event)) {
                     // TODO: reassociate?               
--- a/src/server/daemon/httplistener.c	Tue Nov 10 21:11:06 2015 +0100
+++ b/src/server/daemon/httplistener.c	Tue Nov 10 21:18:51 2015 +0100
@@ -79,7 +79,7 @@
         return http_listener_new(conf);
     }
     
-    HttpListener* newls = malloc(sizeof(HttpListener));
+    HttpListener* newls = calloc(1, sizeof(HttpListener));
     if(newls == NULL) {
         // TODO: error
     }
@@ -329,6 +329,7 @@
                 conn->close = connection_ssl_close;
             }
         } else {
+            conn->ssl = NULL;
             conn->read = connection_read;
             conn->write = connection_write;
             conn->close = connection_close;
--- a/src/server/daemon/ldap_auth.c	Tue Nov 10 21:11:06 2015 +0100
+++ b/src/server/daemon/ldap_auth.c	Tue Nov 10 21:18:51 2015 +0100
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/time.h>
 
 #include <ucx/utils.h>
 
--- a/src/server/util/io.c	Tue Nov 10 21:11:06 2015 +0100
+++ b/src/server/util/io.c	Tue Nov 10 21:18:51 2015 +0100
@@ -34,8 +34,14 @@
 #include <stdlib.h>
 #include <sys/uio.h>
 #include <sys/uio.h>
+
 #ifndef BSD
 #include <sys/sendfile.h>
+#else
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#define WS_NO_SENDFILE
+#define net_sys_sendfile net_fallback_sendfile
+#endif
 #endif
 
 #include "../daemon/vfs.h"
@@ -95,6 +101,7 @@
     return read(st->fd, buf, nbytes);
 }
 
+#ifndef WS_NO_SENDFILE
 ssize_t net_sys_sendfile(SysStream *st, sendfiledata *sfd) {
     ssize_t ret = 0;
     off_t fileoffset = sfd->offset;
@@ -141,6 +148,7 @@
     
     return ret;
 }
+#endif
 
 void net_sys_close(SysStream *st) {
     close(st->fd);
@@ -241,10 +249,11 @@
 
 ssize_t net_http_sendfile(HttpStream *st, sendfiledata *sfd) {  
     ssize_t ret = 0;
+    // TODO: support chunked transfer encoding
     if(st->fd->sendfile) {
         ret = st->fd->sendfile(st->fd, sfd);
     } else {
-        
+        ret = net_fallback_sendfile((IOStream*)st, sfd);
     }
     
     return ret;
@@ -347,13 +356,13 @@
     } else {
         // stream/file does not support sendfile
         // do regular copy
-        return net_copy_file(out, sfd);
+        return net_fallback_sendfile(out, sfd);
     }
     return IO_ERROR;
 }
 
 // private
-ssize_t net_copy_file(IOStream *fd, sendfiledata *sfd) {
+ssize_t net_fallback_sendfile(IOStream *fd, sendfiledata *sfd) {
     char *buf = malloc(4096);
     if(!buf) {
         // TODO: out of memory error
--- a/src/server/util/io.h	Tue Nov 10 21:11:06 2015 +0100
+++ b/src/server/util/io.h	Tue Nov 10 21:18:51 2015 +0100
@@ -116,7 +116,7 @@
 void    net_ssl_finish(SSLStream *st);
 
 /* net_ functions */
-ssize_t net_copy_file(IOStream *fd, sendfiledata *sfd);
+ssize_t net_fallback_sendfile(IOStream *fd, sendfiledata *sfd);
 void    net_finish(SYS_NETFD fd);
 
 #ifdef	__cplusplus

mercurial