ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/s_bsd.c
(Generate patch)

Comparing:
ircd-hybrid/src/s_bsd.c (file contents), Revision 33 by knight, Sun Oct 2 20:50:00 2005 UTC vs.
ircd-hybrid-7.2/src/s_bsd.c (file contents), Revision 871 by db, Fri Sep 14 03:33:44 2007 UTC

# Line 201 | Line 201 | close_connection(struct Client *client_p
201  
202    assert(NULL != client_p);
203  
204 +  if (!IsDead(client_p))
205 +  {
206 +    /* attempt to flush any pending dbufs. Evil, but .. -- adrian */
207 +    /* there is still a chance that we might send data to this socket
208 +     * even if it is marked as blocked (COMM_SELECT_READ handler is called
209 +     * before COMM_SELECT_WRITE). Let's try, nothing to lose.. -adx
210 +     */
211 +    ClearSendqBlocked(client_p);
212 +    send_queued_write(client_p);
213 +  }
214 +
215    if (IsServer(client_p))
216    {
217      ServerStats->is_sv++;
# Line 245 | Line 256 | close_connection(struct Client *client_p
256    else
257      ServerStats->is_ni++;
258  
248  if (!IsDead(client_p))
249  {
250    /* attempt to flush any pending dbufs. Evil, but .. -- adrian */
251    /* there is still a chance that we might send data to this socket
252     * even if it is marked as blocked (COMM_SELECT_READ handler is called
253     * before COMM_SELECT_WRITE). Let's try, nothing to lose.. -adx
254     */
255    ClearSendqBlocked(client_p);
256    send_queued_write(client_p);
257  }
258
259   #ifdef HAVE_LIBCRYPTO
260    if (client_p->localClient->fd.ssl)
261 <    SSL_shutdown(client_p->localClient->fd.ssl);
261 >  {
262 >    SSL_set_shutdown(client_p->localClient->fd.ssl, SSL_RECEIVED_SHUTDOWN);
263 >
264 >    if (!SSL_shutdown(client_p->localClient->fd.ssl))
265 >      SSL_shutdown(client_p->localClient->fd.ssl);
266 >  }
267   #endif
268    if (client_p->localClient->fd.flags.open)
269      fd_close(&client_p->localClient->fd);
# Line 317 | Line 322 | ssl_handshake(int fd, struct Client *cli
322   * any client list yet.
323   */
324   void
325 < add_connection(struct Listener* listener, int fd)
325 > add_connection(struct Listener *listener, struct irc_ssaddr *irn, int fd)
326   {
327    struct Client *new_client;
323  socklen_t len = sizeof(struct irc_ssaddr);
324  struct irc_ssaddr irn;
325  assert(NULL != listener);
328  
329 <  /*
328 <   * get the client socket name from the socket
329 <   * the client has already been checked out in accept_connection
330 <   */
331 <
332 <  memset(&irn, 0, sizeof(irn));
333 <  if (getpeername(fd, (struct sockaddr *)&irn, (socklen_t *)&len))
334 <  {
335 < #ifdef _WIN32
336 <    errno = WSAGetLastError();
337 < #endif
338 <    report_error(L_ALL, "Failed in adding new connection %s :%s",
339 <            get_listener_name(listener), errno);
340 <    ServerStats->is_ref++;
341 < #ifdef _WIN32
342 <    closesocket(fd);
343 < #else
344 <    close(fd);
345 < #endif
346 <    return;
347 <  }
329 >  assert(NULL != listener);
330  
349 #ifdef IPV6
350  remove_ipv6_mapping(&irn);
351 #else
352  irn.ss_len = len;
353 #endif
331    new_client = make_client(NULL);
332 +
333    fd_open(&new_client->localClient->fd, fd, 1,
334            (listener->flags & LISTENER_SSL) ?
335            "Incoming SSL connection" : "Incoming connection");
358  memset(&new_client->localClient->ip, 0, sizeof(struct irc_ssaddr));
336  
337    /*
338     * copy address to 'sockhost' as a string, copy it to host too
339     * so we have something valid to put into error messages...
340     */
341 <  new_client->localClient->port = ntohs(irn.ss_port);
365 <  memcpy(&new_client->localClient->ip, &irn, sizeof(struct irc_ssaddr));
341 >  memcpy(&new_client->localClient->ip, irn, sizeof(struct irc_ssaddr));
342  
343    irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip,
344          new_client->localClient->ip.ss_len,  new_client->sockhost,
345          HOSTIPLEN, NULL, 0, NI_NUMERICHOST);
346    new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family;
371
372  *new_client->host = '\0';
347   #ifdef IPV6
348 <  if (*new_client->sockhost == ':')
348 >  if (new_client->sockhost[0] == ':')
349      strlcat(new_client->host, "0", HOSTLEN+1);
350  
351    if (new_client->localClient->aftype == AF_INET6 &&
# Line 379 | Line 353 | add_connection(struct Listener* listener
353    {
354      strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);
355      strlcat(new_client->host, ".", HOSTLEN+1);
356 <  } else
356 >  }
357 >  else
358   #endif
359      strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);
360  
361 +  new_client->connect_id = ++connect_id;
362    new_client->localClient->listener = listener;
363    ++listener->ref_count;
364  
389  connect_id++;
390  new_client->connect_id = connect_id;
391
365   #ifdef HAVE_LIBCRYPTO
366 <  if ((listener->flags & LISTENER_SSL))
366 >  if (listener->flags & LISTENER_SSL)
367    {
368      if ((new_client->localClient->fd.ssl = SSL_new(ServerInfo.ctx)) == NULL)
369      {
# Line 577 | Line 550 | comm_connect_tcp(fde_t *fd, const char *
550      fd->dns_query = MyMalloc(sizeof(struct DNSQuery));
551      fd->dns_query->ptr = fd;
552      fd->dns_query->callback = comm_connect_dns_callback;
553 <    gethost_byname(host, fd->dns_query);
553 >    if (aftype == AF_INET6)
554 >      gethost_byname_type(host, fd->dns_query, T_AAAA);
555 >    else
556 >      gethost_byname_type(host, fd->dns_query, T_A);
557    }
558    else
559    {

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)