pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:5127:    PIKE_SOCKADDR addr;    int addr_len;    struct pike_string *dest_addr = NULL;    struct pike_string *src_addr = NULL;    struct pike_string *data = NULL;    struct svalue *dest_port = NULL;    struct svalue *src_port = NULL;       int tmp, was_closed = FD < 0;    int fd, sent = 0; +  int nb_mode;       if (args < 4)    {    get_all_args("connect", args, "%S%*", &dest_addr, &dest_port);    }    else if( args == 5 )    {    struct svalue *src_sv;    get_all_args("connect", args, "%S%*%*%*%S",    &dest_addr, &dest_port, &src_sv, &src_port, &data);
pike.git/src/modules/_Stdio/file.c:5182:    } else {    push_svalue(src_port);    ref_push_string(src_addr);    file_open_socket(2);    }    if(UNSAFE_IS_ZERO(Pike_sp-1) || FD < 0)    Pike_error("Stdio.File->connect(): Failed to open socket.\n");    pop_stack();    }    +  nb_mode = !!(THIS->open_mode & FILE_NONBLOCKING); +     fd = FD;    THREADS_ALLOW();    for(;;)    {   #ifdef MSG_FASTOPEN    if( data )    {    tmp = sendto(fd, data->str, data->len, MSG_FASTOPEN,    (struct sockaddr *)&addr, addr_len );    }
pike.git/src/modules/_Stdio/file.c:5203:   #endif    {    tmp=fd_connect(fd, (struct sockaddr *)&addr, addr_len);    }    if( tmp<0 && (errno==EINTR))    continue;    break;    }    THREADS_DISALLOW();    +  /* NB: On success in threaded callback-mode, a suitable callback may +  * already have been called before THREADS_DISALLOW() has finished. +  * +  * We thus mustn't look at the current settings of ourselves, as +  * they may have been changed since before the fd_connect() call. +  */       if(tmp < 0   #ifdef EINPROGRESS -  && !(errno==EINPROGRESS && (THIS->open_mode & FILE_NONBLOCKING)) +  && !(errno == EINPROGRESS && nb_mode)   #endif   #ifdef WSAEWOULDBLOCK -  && !(errno==WSAEWOULDBLOCK && (THIS->open_mode & FILE_NONBLOCKING)) +  && !(errno == WSAEWOULDBLOCK && nb_mode)   #endif   #ifdef EWOULDBLOCK -  && !(errno==EWOULDBLOCK && (THIS->open_mode & FILE_NONBLOCKING)) +  && !(errno == EWOULDBLOCK && nb_mode)   #endif    )    {    /* something went wrong */    ERRNO=errno;    if (was_closed) {    while (fd_close (FD) && errno == EINTR) {}    change_fd_for_box (&THIS->box, -1);    errno = ERRNO;    }