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

Comparing ircd-hybrid-7.2/src/s_bsd.c (file contents):
Revision 451 by michael, Sun Feb 12 16:19:54 2006 UTC vs.
Revision 948 by michael, Tue Jul 21 17:34:06 2009 UTC

# Line 49 | Line 49
49   #include "s_conf.h"
50   #include "s_log.h"
51   #include "s_serv.h"
52 #include "s_stats.h"
52   #include "send.h"
53   #include "memory.h"
54   #include "s_user.h"
# Line 201 | Line 200 | close_connection(struct Client *client_p
200  
201    assert(NULL != client_p);
202  
203 +  if (!IsDead(client_p))
204 +  {
205 +    /* attempt to flush any pending dbufs. Evil, but .. -- adrian */
206 +    /* there is still a chance that we might send data to this socket
207 +     * even if it is marked as blocked (COMM_SELECT_READ handler is called
208 +     * before COMM_SELECT_WRITE). Let's try, nothing to lose.. -adx
209 +     */
210 +    ClearSendqBlocked(client_p);
211 +    send_queued_write(client_p);
212 +  }
213 +
214    if (IsServer(client_p))
215    {
216 <    ServerStats->is_sv++;
217 <    ServerStats->is_sbs += client_p->localClient->send.bytes;
218 <    ServerStats->is_sbr += client_p->localClient->recv.bytes;
219 <    ServerStats->is_sti += CurrentTime - client_p->firsttime;
216 >    ++ServerStats.is_sv;
217 >    ServerStats.is_sbs += client_p->localClient->send.bytes;
218 >    ServerStats.is_sbr += client_p->localClient->recv.bytes;
219 >    ServerStats.is_sti += CurrentTime - client_p->firsttime;
220  
221      /* XXX Does this even make any sense at all anymore?
222       * scheduling a 'quick' reconnect could cause a pile of
# Line 237 | Line 247 | close_connection(struct Client *client_p
247    }
248    else if (IsClient(client_p))
249    {
250 <    ServerStats->is_cl++;
251 <    ServerStats->is_cbs += client_p->localClient->send.bytes;
252 <    ServerStats->is_cbr += client_p->localClient->recv.bytes;
253 <    ServerStats->is_cti += CurrentTime - client_p->firsttime;
250 >    ++ServerStats.is_cl;
251 >    ServerStats.is_cbs += client_p->localClient->send.bytes;
252 >    ServerStats.is_cbr += client_p->localClient->recv.bytes;
253 >    ServerStats.is_cti += CurrentTime - client_p->firsttime;
254    }
255    else
256 <    ServerStats->is_ni++;
247 <
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 <  }
256 >    ++ServerStats.is_ni;
257  
258   #ifdef HAVE_LIBCRYPTO
259    if (client_p->localClient->fd.ssl)
# Line 322 | Line 321 | ssl_handshake(int fd, struct Client *cli
321   * any client list yet.
322   */
323   void
324 < add_connection(struct Listener* listener, int fd)
324 > add_connection(struct Listener *listener, struct irc_ssaddr *irn, int fd)
325   {
326    struct Client *new_client;
328  socklen_t len = sizeof(struct irc_ssaddr);
329  struct irc_ssaddr irn;
330  assert(NULL != listener);
331
332  /*
333   * get the client socket name from the socket
334   * the client has already been checked out in accept_connection
335   */
327  
328 <  memset(&irn, 0, sizeof(irn));
338 <  if (getpeername(fd, (struct sockaddr *)&irn, (socklen_t *)&len))
339 <  {
340 < #ifdef _WIN32
341 <    errno = WSAGetLastError();
342 < #endif
343 <    report_error(L_ALL, "Failed in adding new connection %s :%s",
344 <            get_listener_name(listener), errno);
345 <    ServerStats->is_ref++;
346 < #ifdef _WIN32
347 <    closesocket(fd);
348 < #else
349 <    close(fd);
350 < #endif
351 <    return;
352 <  }
328 >  assert(NULL != listener);
329  
354 #ifdef IPV6
355  remove_ipv6_mapping(&irn);
356 #else
357  irn.ss_len = len;
358 #endif
330    new_client = make_client(NULL);
331 +
332    fd_open(&new_client->localClient->fd, fd, 1,
333            (listener->flags & LISTENER_SSL) ?
334            "Incoming SSL connection" : "Incoming connection");
363  memset(&new_client->localClient->ip, 0, sizeof(struct irc_ssaddr));
335  
336    /*
337     * copy address to 'sockhost' as a string, copy it to host too
338     * so we have something valid to put into error messages...
339     */
340 <  memcpy(&new_client->localClient->ip, &irn, sizeof(struct irc_ssaddr));
340 >  memcpy(&new_client->localClient->ip, irn, sizeof(struct irc_ssaddr));
341  
342    irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip,
343          new_client->localClient->ip.ss_len,  new_client->sockhost,
344          HOSTIPLEN, NULL, 0, NI_NUMERICHOST);
345    new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family;
375
376  *new_client->host = '\0';
346   #ifdef IPV6
347 <  if (*new_client->sockhost == ':')
347 >  if (new_client->sockhost[0] == ':')
348      strlcat(new_client->host, "0", HOSTLEN+1);
349  
350    if (new_client->localClient->aftype == AF_INET6 &&
# Line 383 | Line 352 | add_connection(struct Listener* listener
352    {
353      strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);
354      strlcat(new_client->host, ".", HOSTLEN+1);
355 <  } else
355 >  }
356 >  else
357   #endif
358      strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);
359  
360    new_client->localClient->listener = listener;
361    ++listener->ref_count;
362  
393  connect_id++;
394  new_client->connect_id = connect_id;
395
363   #ifdef HAVE_LIBCRYPTO
364 <  if ((listener->flags & LISTENER_SSL))
364 >  if (listener->flags & LISTENER_SSL)
365    {
366      if ((new_client->localClient->fd.ssl = SSL_new(ServerInfo.ctx)) == NULL)
367      {
# Line 581 | Line 548 | comm_connect_tcp(fde_t *fd, const char *
548      fd->dns_query = MyMalloc(sizeof(struct DNSQuery));
549      fd->dns_query->ptr = fd;
550      fd->dns_query->callback = comm_connect_dns_callback;
551 <    gethost_byname(host, fd->dns_query);
551 >    if (aftype == AF_INET6)
552 >      gethost_byname_type(host, fd->dns_query, T_AAAA);
553 >    else
554 >      gethost_byname_type(host, fd->dns_query, T_A);
555    }
556    else
557    {

Diff Legend

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