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 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid-7.2/src/s_bsd.c (file contents), 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)
260 <    SSL_shutdown(client_p->localClient->fd.ssl);
260 >  {
261 >    SSL_set_shutdown(client_p->localClient->fd.ssl, SSL_RECEIVED_SHUTDOWN);
262 >
263 >    if (!SSL_shutdown(client_p->localClient->fd.ssl))
264 >      SSL_shutdown(client_p->localClient->fd.ssl);
265 >  }
266   #endif
267    if (client_p->localClient->fd.flags.open)
268      fd_close(&client_p->localClient->fd);
# Line 317 | 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;
323  socklen_t len = sizeof(struct irc_ssaddr);
324  struct irc_ssaddr irn;
325  assert(NULL != listener);
326
327  /*
328   * get the client socket name from the socket
329   * the client has already been checked out in accept_connection
330   */
327  
328 <  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 <  }
328 >  assert(NULL != listener);
329  
349 #ifdef IPV6
350  remove_ipv6_mapping(&irn);
351 #else
352  irn.ss_len = len;
353 #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");
358  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 <  new_client->localClient->port = ntohs(irn.ss_port);
365 <  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;
371
372  *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 379 | 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  
389  connect_id++;
390  new_client->connect_id = connect_id;
391
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 577 | 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    {

Comparing:
ircd-hybrid/src/s_bsd.c (property svn:keywords), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid-7.2/src/s_bsd.c (property svn:keywords), Revision 948 by michael, Tue Jul 21 17:34:06 2009 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

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