Ticket #896: cage.patch

File cage.patch, 2.9 KB (added by jimmy, 12 years ago)
  • src/io/socket_win32.c

     
    7777Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, int proto) 
    7878{ 
    7979    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); 
    8281    if (sock >= 0) { 
     82        int i = 1; 
    8383        setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&i, sizeof (i)); 
    8484        Parrot_io_set_os_handle(interp, s, sock); 
    8585        SOCKADDR_REMOTE(s)->sin_family = fam; 
     
    102102Parrot_io_connect_win32(PARROT_INTERP, ARGMOD(PMC *socket), ARGIN(PMC *r)) 
    103103{ 
    104104    ASSERT_ARGS(Parrot_io_connect_win32) 
    105     Parrot_Socket_attributes * io = PARROT_SOCKET(socket); 
     105    const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 
    106106 
    107107    if (!r) 
    108108        return -1; 
     
    141141Parrot_io_bind_win32(PARROT_INTERP, ARGMOD(PMC *socket), ARGMOD(PMC *sockaddr)) 
    142142{ 
    143143    ASSERT_ARGS(Parrot_io_bind_win32) 
    144     Parrot_Socket_attributes * io = PARROT_SOCKET(socket); 
     144    const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 
    145145    struct sockaddr_in * saddr; 
    146146 
    147147    if (!sockaddr) 
     
    174174Parrot_io_listen_win32(SHIM_INTERP, ARGMOD(PMC *socket), INTVAL sec) 
    175175{ 
    176176    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) { 
    179179        return -1; 
    180180    } 
    181181    return 0; 
     
    197197Parrot_io_accept_win32(PARROT_INTERP, ARGMOD(PMC *socket)) 
    198198{ 
    199199    ASSERT_ARGS(Parrot_io_accept_win32) 
    200     Parrot_Socket_attributes * io = PARROT_SOCKET(socket); 
     200    const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 
    201201    PMC * newio   = Parrot_io_new_socket_pmc(interp, 
    202202            PIO_F_SOCKET | PIO_F_READ|PIO_F_WRITE); 
    203203    Parrot_Socklen_t    addrlen = sizeof (struct sockaddr_in); 
     
    240240{ 
    241241    ASSERT_ARGS(Parrot_io_send_win32) 
    242242    int error, bytes, byteswrote; 
    243     Parrot_Socket_attributes * io = PARROT_SOCKET(socket); 
     243    const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 
    244244 
    245245    bytes = s->bufused; 
    246246    byteswrote = 0; 
     
    295295    int error; 
    296296    unsigned int bytesread = 0; 
    297297    char buf[2048]; 
    298     Parrot_Socket_attributes * io = PARROT_SOCKET(socket); 
     298    const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 
    299299 
    300300AGAIN: 
    301301    if ((error = recv((int)io->os_handle, buf, 2048, 0)) >= 0) { 
     
    359359    int n; 
    360360    fd_set r, w, e; 
    361361    struct timeval t; 
    362     Parrot_Socket_attributes * io = PARROT_SOCKET(socket); 
     362    const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket); 
    363363 
    364364    t.tv_sec = sec; 
    365365    t.tv_usec = usec;