Changeset 4132
- Timestamp:
- Jan 17, 2014, 10:27:20 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanoscale/server.c
r4131 r4132 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* ====================================================================== 3 * Copyright (c) 2004-2014 HUBzero Foundation, LLC 4 * ---------------------------------------------------------------------- 5 * See the file "license.terms" for information on usage and 6 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 * ====================================================================== 8 */ 2 9 #define _GNU_SOURCE 3 10 #include <sys/socket.h> … … 492 499 #ifdef HAVE_ACCEPT4 493 500 sock = accept4(serverPtr->listenerFd, (struct sockaddr *)&newaddr, 494 &length, SOCK_CLOEXEC);501 &length, SOCK_CLOEXEC); 495 502 #else 496 503 sock = accept(serverPtr->listenerFd, (struct sockaddr *)&newaddr, 497 &length);504 &length); 498 505 #endif 499 506 if (sock < 0) { … … 600 607 } 601 608 } 602 /* Dup the socket to descriptors, normally 3 and 4 */ 603 if (dup2(sock, serverPtr->inputFd) < 0) { /* Stdin */ 604 ERROR("%s: can't dup stdin: %s", serverPtr->name, 605 strerror(errno)); 606 exit(1); 607 } 608 if (dup2(sock, serverPtr->outputFd) < 0) { /* Stdout */ 609 ERROR("%s: can't dup stdout: %s", serverPtr->name, 609 /* Dup the socket to descriptors, e.g. 3 and 4 */ 610 if (dup2(sock, serverPtr->inputFd) < 0) { /* input */ 611 ERROR("%s: can't dup socket to fd %d: %s", 612 serverPtr->name, serverPtr->inputFd, 610 613 strerror(errno)); 611 614 exit(1); 612 615 } 613 for(i = serverPtr->outputFd + 1; i <= FD_SETSIZE; i++) { 616 if (serverPtr->outputFd != serverPtr->inputFd) { 617 if (dup2(sock, serverPtr->outputFd) < 0) { /* output */ 618 ERROR("%s: can't dup socket to fd %d: %s", 619 serverPtr->name, serverPtr->outputFd, 620 strerror(errno)); 621 exit(1); 622 } 623 } 624 for (i = serverPtr->outputFd + 1; i <= FD_SETSIZE; i++) { 614 625 close(i); /* Close all the other descriptors. */ 615 626 }
Note: See TracChangeset
for help on using the changeset viewer.