r113: GCC4 warning fixes
[nbd.git] / nbd-server.c
index 256dd5d..9fb9517 100644 (file)
 #define F_AUTOREADONLY 8  /**< flag to tell us a file is set to autoreadonly */
 GHashTable *children;
 char pidfname[256]; /**< name of our PID file */
+char default_authname[] = "/etc/nbd_server.allow"; /**< default name of allow file */
 
 /**
  * Variables associated with a server.
@@ -296,6 +297,7 @@ SERVER* cmdline(int argc, char *argv[]) {
                case 'm':
                        serve->flags |= F_MULTIFILE;
                        serve->hunksize = 1*GIGA;
+                       serve->authname = default_authname;
                        break;
                case 'c': 
                        serve->flags |=F_COPYONWRITE;
@@ -352,7 +354,6 @@ SERVER* cmdline(int argc, char *argv[]) {
 void sigchld_handler(int s) {
         int* status=NULL;
        int* i;
-       char buf[80];
        pid_t pid;
 
        while((pid=wait(status)) > 0) {
@@ -391,7 +392,6 @@ void killchild(gpointer key, gpointer value, gpointer user_data) {
  * is severely wrong).
  **/
 void sigterm_handler(int s) {
-       int i;
        int parent=0;
 
        g_hash_table_foreach(children, killchild, &parent);
@@ -722,6 +722,7 @@ int mainloop(CLIENT *client) {
                writeit(client->net, buf, len + sizeof(struct nbd_reply));
                DEBUG("OK!\n");
        }
+       return 0;
 }
 
 /**
@@ -780,7 +781,6 @@ int splitexport(CLIENT* client) {
  * @param net A network socket connected to an nbd client
  **/
 void serveconnection(CLIENT *client) {
-       char buf[80];
        splitexport(client);
 
        if (!client->server->expected_size) {
@@ -877,7 +877,6 @@ void setup_serve(SERVER* serve) {
        struct sockaddr_in addrin;
        struct sigaction sa;
        int addrinlen = sizeof(addrin);
-       int newpid, i;
 #ifndef sun
        int yes=1;
 #else
@@ -920,10 +919,12 @@ void setup_serve(SERVER* serve) {
 /**
  * Loop through the available servers, and serve them.
  *
+ * Actually, right now we only handle one server. Will change that for
+ * 2.9.
  **/
 int serveloop(SERVER* serve) {
        struct sockaddr_in addrin;
-       int addrinlen=sizeof(addrin);
+       socklen_t addrinlen=sizeof(addrin);
        for(;;) {
                CLIENT *client;
                int net;
@@ -958,7 +959,7 @@ int serveloop(SERVER* serve) {
                }
                /* child */
                g_hash_table_destroy(children);
-               close(sock) ;
+               close(serve->socket) ;
 #endif // NOFORK
                msg2(LOG_INFO,"Starting to serve") ;
                serveconnection(client);