emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem report #30


From: Dan Nicolaescu
Subject: Problem report #30
Date: Sat, 08 Apr 2006 23:59:58 -0700

ERROR
CID: 30
Checker: NEGATIVE_RETURNS (help)
File: emacs/src/process.c
Function: Fmake_network_process
Description: Tracked variable "inch" used as index to array "chan_process"


Event var_tested_neg: Variable "s" assigned NEGATIVE
Also see events: [alias_assign][alias_assign][negative_returns]

3111      s = -1;
3112    

At conditional (1): "lres != 0" taking false path

3113      for (lres = res; lres; lres = lres->ai_next)
3114        {
3115          int optn, optbits;
3116    
3117        retry_connect:
3118    
3119          s = socket (lres->ai_family, lres->ai_socktype, 
lres->ai_protocol);
3120          if (s < 0)
3121            {
3122              xerrno = errno;
3123              continue;
3124            }
3125    
3126    #ifdef DATAGRAM_SOCKETS
3127          if (!is_server && socktype == SOCK_DGRAM)
3128            break;
3129    #endif /* DATAGRAM_SOCKETS */
3130    
3131    #ifdef NON_BLOCKING_CONNECT
3132          if (is_non_blocking_client)
3133            {
3134    #ifdef O_NONBLOCK
3135              ret = fcntl (s, F_SETFL, O_NONBLOCK);
3136    #else
3137              ret = fcntl (s, F_SETFL, O_NDELAY);
3138    #endif
3139              if (ret < 0)
3140                {
3141                  xerrno = errno;
3142                  emacs_close (s);
3143                  s = -1;
3144                  continue;
3145                }
3146            }
3147    #endif
3148    
3149          /* Make us close S if quit.  */
3150          record_unwind_protect (close_file_unwind, make_number (s));
3151    
3152          /* Parse network options in the arg list.
3153             We simply ignore anything which isn't a known option 
(including other keywords).
3154             An error is signalled if setting a known option fails.  */
3155          for (optn = optbits = 0; optn < nargs-1; optn += 2)
3156            optbits |= set_socket_option (s, args[optn], args[optn+1]);
3157    
3158          if (is_server)
3159            {
3160              /* Configure as a server socket.  */
3161    
3162              /* SO_REUSEADDR = 1 is default for server sockets; must 
specify
3163                 explicit :reuseaddr key to override this.  */
3164    #ifdef HAVE_LOCAL_SOCKETS
3165              if (family != AF_LOCAL)
3166    #endif
3167                if (!(optbits & (1 << OPIX_REUSEADDR)))
3168                  {
3169                    int optval = 1;
3170                    if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &optval, 
sizeof optval))
3171                      report_file_error ("Cannot set reuse option on server 
socket", Qnil);
3172                  }
3173    
3174              if (bind (s, lres->ai_addr, lres->ai_addrlen))
3175                report_file_error ("Cannot bind server socket", Qnil);
3176    
3177    #ifdef HAVE_GETSOCKNAME
3178              if (EQ (service, Qt))
3179                {
3180                  struct sockaddr_in sa1;
3181                  int len1 = sizeof (sa1);
3182                  if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
3183                    {
3184                      ((struct sockaddr_in *)(lres->ai_addr))->sin_port = 
sa1.sin_port;
3185                      service = make_number (ntohs (sa1.sin_port));
3186                      contact = Fplist_put (contact, QCservice, service);
3187                    }
3188                }
3189    #endif
3190    
3191              if (socktype == SOCK_STREAM && listen (s, backlog))
3192                report_file_error ("Cannot listen on server socket", Qnil);
3193    
3194              break;
3195            }
3196    
3197          immediate_quit = 1;
3198          QUIT;
3199    
3200          /* This turns off all alarm-based interrupts; the
3201             bind_polling_period call above doesn't always turn all the
3202             short-interval ones off, especially if interrupt_input is
3203             set.
3204    
3205             It'd be nice to be able to control the connect timeout
3206             though.  Would non-blocking connect calls be portable?
3207    
3208             This used to be conditioned by HAVE_GETADDRINFO.  Why?  */
3209    
3210          turn_on_atimers (0);
3211    
3212          ret = connect (s, lres->ai_addr, lres->ai_addrlen);
3213          xerrno = errno;
3214    
3215          turn_on_atimers (1);
3216    
3217          if (ret == 0 || xerrno == EISCONN)
3218            {
3219              /* The unwind-protect will be discarded afterwards.
3220                 Likewise for immediate_quit.  */
3221              break;
3222            }
3223    
3224    #ifdef NON_BLOCKING_CONNECT
3225    #ifdef EINPROGRESS
3226          if (is_non_blocking_client && xerrno == EINPROGRESS)
3227            break;
3228    #else
3229    #ifdef EWOULDBLOCK
3230          if (is_non_blocking_client && xerrno == EWOULDBLOCK)
3231            break;
3232    #endif
3233    #endif
3234    #endif
3235    
3236          immediate_quit = 0;
3237    
3238          /* Discard the unwind protect closing S.  */
3239          specpdl_ptr = specpdl + count1;
3240          emacs_close (s);
3241          s = -1;
3242    
3243          if (xerrno == EINTR)
3244            goto retry_connect;
3245        }
3246    

At conditional (2): "s >= 0" taking false path

3247      if (s >= 0)
3248        {
3249    #ifdef DATAGRAM_SOCKETS
3250          if (socktype == SOCK_DGRAM)
3251            {
3252              if (datagram_address[s].sa)
3253                abort ();
3254              datagram_address[s].sa = (struct sockaddr *) xmalloc 
(lres->ai_addrlen);
3255              datagram_address[s].len = lres->ai_addrlen;
3256              if (is_server)
3257                {
3258                  Lisp_Object remote;
3259                  bzero (datagram_address[s].sa, lres->ai_addrlen);
3260                  if (remote = Fplist_get (contact, QCremote), !NILP 
(remote))
3261                    {
3262                      int rfamily, rlen;
3263                      rlen = get_lisp_to_sockaddr_size (remote, &rfamily);
3264                      if (rfamily == lres->ai_family && rlen == 
lres->ai_addrlen)
3265                        conv_lisp_to_sockaddr (rfamily, remote,
3266                                               datagram_address[s].sa, 
rlen);
3267                    }
3268                }
3269              else
3270                bcopy (lres->ai_addr, datagram_address[s].sa, 
lres->ai_addrlen);
3271            }
3272    #endif
3273          contact = Fplist_put (contact, QCaddress,
3274                                conv_sockaddr_to_lisp (lres->ai_addr, 
lres->ai_addrlen));
3275    #ifdef HAVE_GETSOCKNAME
3276          if (!is_server)
3277            {
3278              struct sockaddr_in sa1;
3279              int len1 = sizeof (sa1);
3280              if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
3281                contact = Fplist_put (contact, QClocal,
3282                                      conv_sockaddr_to_lisp (&sa1, len1));
3283            }
3284    #endif
3285        }
3286    
3287    #ifdef HAVE_GETADDRINFO

At conditional (3): "res != &ai" taking true path

3288      if (res != &ai)
3289        freeaddrinfo (res);
3290    #endif
3291    
3292      immediate_quit = 0;
3293    
3294      /* Discard the unwind protect for closing S, if any.  */
3295      specpdl_ptr = specpdl + count1;
3296    
3297      /* Unwind bind_polling_period and request_sigio.  */
3298      unbind_to (count, Qnil);
3299    

At conditional (4): "s < 0" taking true path

3300      if (s < 0)
3301        {
3302          /* If non-blocking got this far - and failed - assume 
non-blocking is
3303             not supported after all.  This is probably a wrong assumption, 
but
3304             the normal blocking calls to open-network-stream handles this 
error
3305             better.  */

At conditional (5): "is_non_blocking_client != 0" taking false path

3306          if (is_non_blocking_client)
3307              return Qnil;
3308    
3309          errno = xerrno;

At conditional (6): "is_server != 0" taking true path

3310          if (is_server)
3311            report_file_error ("make server process failed", contact);
3312          else
3313            report_file_error ("make client process failed", contact);
3314        }
3315    
3316    #endif /* not TERM */
3317    

Event alias_assign: Variable "s" aliased to variable "inch"
Also see events: [var_tested_neg][alias_assign][negative_returns]

3318      inch = s;

Event alias_assign: Variable "s" aliased to variable "outch"
Also see events: [var_tested_neg][alias_assign][negative_returns]

3319      outch = s;
3320    

At conditional (7): "buffer != Qnil" taking true path

3321      if (!NILP (buffer))
3322        buffer = Fget_buffer_create (buffer);
3323      proc = make_process (name);
3324    

Event negative_returns: Tracked variable "inch" used as index to array 
"chan_process"
Also see events: [var_tested_neg][alias_assign][alias_assign]

3325      chan_process[inch] = proc;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]