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

version» Context lines:

pike.git/src/modules/_Stdio/file.c:5128:    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; +  int old_events; +  int e;       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:5185:    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);    +  /* Inhibit the backend for this fd while connect(2) is running. */ +  if ((old_events = THIS->box.events)) { +  set_fd_callback_events(&(THIS->box), 0, THIS->box.flags); +  } +     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:5206:   #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. +  e = errno; +  +  if (old_events) { +  /* Reenable the backend. */ +  set_fd_callback_events(&(THIS->box), old_events, THIS->box.flags); +  } +  +  errno = e; +  +  /* NB: On success in threaded callback-mode, some other thread may +  * have messed with us 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 && nb_mode)   #endif   #ifdef WSAEWOULDBLOCK