Ticket #896: cage.patch
File cage.patch, 2.9 KB (added by jimmy, 12 years ago) |
---|
-
src/io/socket_win32.c
77 77 Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, int proto) 78 78 { 79 79 ASSERT_ARGS(Parrot_io_socket_win32) 80 int sock, i = 1; 81 sock = socket(fam, type, proto); 80 const int sock = socket(fam, type, proto); 82 81 if (sock >= 0) { 82 int i = 1; 83 83 setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&i, sizeof (i)); 84 84 Parrot_io_set_os_handle(interp, s, sock); 85 85 SOCKADDR_REMOTE(s)->sin_family = fam; … … 102 102 Parrot_io_connect_win32(PARROT_INTERP, ARGMOD(PMC *socket), ARGIN(PMC *r)) 103 103 { 104 104 ASSERT_ARGS(Parrot_io_connect_win32) 105 Parrot_Socket_attributes *io = PARROT_SOCKET(socket);105 const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 106 106 107 107 if (!r) 108 108 return -1; … … 141 141 Parrot_io_bind_win32(PARROT_INTERP, ARGMOD(PMC *socket), ARGMOD(PMC *sockaddr)) 142 142 { 143 143 ASSERT_ARGS(Parrot_io_bind_win32) 144 Parrot_Socket_attributes *io = PARROT_SOCKET(socket);144 const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 145 145 struct sockaddr_in * saddr; 146 146 147 147 if (!sockaddr) … … 174 174 Parrot_io_listen_win32(SHIM_INTERP, ARGMOD(PMC *socket), INTVAL sec) 175 175 { 176 176 ASSERT_ARGS(Parrot_io_listen_win32) 177 Parrot_Socket_attributes *io = PARROT_SOCKET(socket);178 if ((listen( (int)io->os_handle, sec)) == -1) {177 const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 178 if ((listen(io->os_handle, sec)) == -1) { 179 179 return -1; 180 180 } 181 181 return 0; … … 197 197 Parrot_io_accept_win32(PARROT_INTERP, ARGMOD(PMC *socket)) 198 198 { 199 199 ASSERT_ARGS(Parrot_io_accept_win32) 200 Parrot_Socket_attributes *io = PARROT_SOCKET(socket);200 const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 201 201 PMC * newio = Parrot_io_new_socket_pmc(interp, 202 202 PIO_F_SOCKET | PIO_F_READ|PIO_F_WRITE); 203 203 Parrot_Socklen_t addrlen = sizeof (struct sockaddr_in); … … 240 240 { 241 241 ASSERT_ARGS(Parrot_io_send_win32) 242 242 int error, bytes, byteswrote; 243 Parrot_Socket_attributes *io = PARROT_SOCKET(socket);243 const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 244 244 245 245 bytes = s->bufused; 246 246 byteswrote = 0; … … 295 295 int error; 296 296 unsigned int bytesread = 0; 297 297 char buf[2048]; 298 Parrot_Socket_attributes *io = PARROT_SOCKET(socket);298 const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 299 299 300 300 AGAIN: 301 301 if ((error = recv((int)io->os_handle, buf, 2048, 0)) >= 0) { … … 359 359 int n; 360 360 fd_set r, w, e; 361 361 struct timeval t; 362 Parrot_Socket_attributes *io = PARROT_SOCKET(socket);362 const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 363 363 364 364 t.tv_sec = sec; 365 365 t.tv_usec = usec;