diff options
Diffstat (limited to 'src/Sockets.c')
-rw-r--r-- | src/Sockets.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/Sockets.c b/src/Sockets.c index 51fc9a7..8917797 100644 --- a/src/Sockets.c +++ b/src/Sockets.c @@ -94,7 +94,7 @@ typedef struct ISOSocket static int byteswap(void *buf,CCTK_INT8 nelements,int elementsize); -IsoCommand *Iso_PollCommand(cGH *GH,IsoCommand *cmd); +IsoCommand *Iso_PollCommand(const cGH *GH,IsoCommand *cmd); int Iso_Write(isoSocket *connection, const char *buffer, size_t count); static SOCKET Iso_MakeSocket (unsigned long port, int *hunt); @@ -102,10 +102,10 @@ static SOCKET Iso_MakeSocket (unsigned long port, int *hunt); static isoSocket *SocketCreate(unsigned long int filedes, isoSocket **list); static void SocketDestroy(isoSocket *this, isoSocket **list); static void SocketClose(isoSocket *this); -int Iso_SetupServer(cGH *GH,isosurfacerGH *myGH, +int Iso_SetupServer(const cGH *GH,isosurfacerGH *myGH, int dataport, int controlport, int queue_size, int hunt); int Iso_ShutdownServer(void); -int Iso_Poll(cGH *GH, long sec, long usec); +int Iso_Poll(const cGH *GH, long sec, long usec); int Iso_Read(isoSocket *connection, char *buffer, size_t count); int IsoWriteDataToClients(const char *metadata, CCTK_INT8 size, @@ -164,7 +164,7 @@ static char *advertised_filename = NULL; @endhistory @@*/ -int Iso_SetupServer(cGH *GH,isosurfacerGH *myGH,int dataport, int controlport, int queue_size, int hunt) +int Iso_SetupServer(const cGH *GH,isosurfacerGH *myGH,int dataport, int controlport, int queue_size, int hunt) { int realdport; int realcport; @@ -301,7 +301,7 @@ int Iso_ShutdownServer(void) @endhistory @@*/ -int Iso_Poll(cGH *GH, long sec, long usec) +int Iso_Poll(const cGH *GH, long sec, long usec) { #ifdef HAVE_SOCKLEN_T @@ -315,6 +315,15 @@ int Iso_Poll(cGH *GH, long sec, long usec) struct sockaddr_in clientname; struct timeval timeout; struct timeval *real_timeout; + /*** FIXME: can CCTK_Abort() have a 'const cGH *' parameter ?? ***/ + union + { + const cGH *const_ptr; + cGH *non_const_ptr; + } GH_fake_const; + + + GH_fake_const.const_ptr = GH; if(CCTK_MyProc(GH) != 0) return 0; /* not the root processor */ @@ -336,7 +345,7 @@ int Iso_Poll(cGH *GH, long sec, long usec) if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))) { perror ("select"); - CCTK_Abort(GH, EXIT_FAILURE); + CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE); } /* Service all the sockets with input pending. */ @@ -351,7 +360,7 @@ int Iso_Poll(cGH *GH, long sec, long usec) if (ERROR_CHECK(new)) { perror ("accept"); - CCTK_Abort(GH, EXIT_FAILURE); + CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE); } fprintf (stderr, "Isosurfacer: data connect to port %u from host %s, port %hd.\n", @@ -373,7 +382,7 @@ int Iso_Poll(cGH *GH, long sec, long usec) if (ERROR_CHECK(new)) { perror ("accept"); - CCTK_Abort(GH, EXIT_FAILURE); + CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE); } fprintf (stderr, "Isosurfacer: control connect to port %u from host %s, port %hd.\n", @@ -387,13 +396,22 @@ int Iso_Poll(cGH *GH, long sec, long usec) return 0; } -IsoCommand *Iso_PollCommand(cGH *GH,IsoCommand *cmd) +IsoCommand *Iso_PollCommand(const cGH *GH,IsoCommand *cmd) { fd_set read_fd_set; struct timeval timeout; struct timeval *real_timeout; isoSocket *this; + /*** FIXME: can CCTK_Abort() have a 'const cGH *' parameter ?? ***/ + union + { + const cGH *const_ptr; + cGH *non_const_ptr; + } GH_fake_const; + + + GH_fake_const.const_ptr = GH; if(CCTK_MyProc(GH) != 0) return 0; /* not the root processor */ @@ -408,7 +426,7 @@ IsoCommand *Iso_PollCommand(cGH *GH,IsoCommand *cmd) if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))){ perror ("select"); - CCTK_Abort(GH, EXIT_FAILURE); + CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE); } /* get next command on the control socket list */ for(this = controlsocklist; this; this = this->next){ |