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-7.3/src/s_bsd.c (file contents), Revision 1122 by michael, Mon Jan 10 09:14:19 2011 UTC vs.
ircd-hybrid-8/src/s_bsd.c (file contents), Revision 1391 by michael, Tue May 1 15:34:29 2012 UTC

# Line 30 | Line 30
30   #include "fdlist.h"
31   #include "s_bsd.h"
32   #include "client.h"
33 #include "common.h"
33   #include "dbuf.h"
34   #include "event.h"
35   #include "irc_string.h"
37 #include "irc_getnameinfo.h"
38 #include "irc_getaddrinfo.h"
36   #include "ircd.h"
37   #include "listener.h"
38   #include "numeric.h"
39   #include "packet.h"
40   #include "irc_res.h"
44 #include "inet_misc.h"
41   #include "restart.h"
42   #include "s_auth.h"
43 < #include "s_conf.h"
44 < #include "s_log.h"
43 > #include "conf.h"
44 > #include "log.h"
45   #include "s_serv.h"
46   #include "send.h"
47   #include "memory.h"
# Line 134 | Line 130 | report_error(int level, const char* text
130    who = (who) ? who : "";
131  
132    sendto_realops_flags(UMODE_DEBUG, level, text, who, strerror(error));
133 <  log_oper_action(LOG_IOERR_TYPE, NULL, "%s %s %s\n", who, text, strerror(error));
138 <  ilog(L_ERROR, text, who, strerror(error));
133 >  ilog(LOG_TYPE_IRCD, text, who, strerror(error));
134   }
135  
136   /*
# Line 181 | Line 176 | init_comm(void)
176   void
177   close_connection(struct Client *client_p)
178   {
184  struct ConfItem *conf;
179    struct AccessItem *aconf;
180    struct ClassItem *aclass;
181 +  dlink_node *ptr = NULL;
182  
183 <  assert(NULL != client_p);
183 >  assert(client_p);
184  
185    if (!IsDead(client_p))
186    {
# Line 198 | Line 193 | close_connection(struct Client *client_p
193      send_queued_write(client_p);
194    }
195  
196 <  if (IsServer(client_p))
196 >  if (IsClient(client_p))
197 >  {
198 >    ++ServerStats.is_cl;
199 >    ServerStats.is_cbs += client_p->localClient->send.bytes;
200 >    ServerStats.is_cbr += client_p->localClient->recv.bytes;
201 >    ServerStats.is_cti += CurrentTime - client_p->localClient->firsttime;
202 >  }
203 >  else if (IsServer(client_p))
204    {
205      ++ServerStats.is_sv;
206      ServerStats.is_sbs += client_p->localClient->send.bytes;
207      ServerStats.is_sbr += client_p->localClient->recv.bytes;
208 <    ServerStats.is_sti += CurrentTime - client_p->firsttime;
208 >    ServerStats.is_sti += CurrentTime - client_p->localClient->firsttime;
209  
210 <    /* XXX Does this even make any sense at all anymore?
209 <     * scheduling a 'quick' reconnect could cause a pile of
210 <     * nick collides under TSora protocol... -db
211 <     */
212 <    /*
213 <     * If the connection has been up for a long amount of time, schedule
214 <     * a 'quick' reconnect, else reset the next-connect cycle.
215 <     */
216 <    if ((conf = find_conf_exact(SERVER_TYPE, client_p->name,
217 <                                client_p->username, client_p->host)))
210 >    DLINK_FOREACH(ptr, server_items.head)
211      {
212 +      struct ConfItem *conf = ptr->data;
213 +
214 +      if (irccmp(conf->name, client_p->name))
215 +        continue;
216 +
217        /*
218 <       * Reschedule a faster reconnect, if this was a automatically
219 <       * connected configuration entry. (Note that if we have had
222 <       * a rehash in between, the status has been changed to
223 <       * CONF_ILLEGAL). But only do this if it was a "good" link.
218 >       * Reset next-connect cycle of all connect{} blocks that match
219 >       * this servername.
220         */
221        aconf  = map_to_conf(conf);
222        aclass = map_to_conf(aconf->class_ptr);
223 <      aconf->hold = time(NULL);
228 <      aconf->hold += (aconf->hold - client_p->since > HANGONGOODLINK) ?
229 <        HANGONRETRYDELAY : ConFreq(aclass);
223 >      aconf->hold = CurrentTime + aclass->con_freq;
224      }
225    }
232  else if (IsClient(client_p))
233  {
234    ++ServerStats.is_cl;
235    ServerStats.is_cbs += client_p->localClient->send.bytes;
236    ServerStats.is_cbr += client_p->localClient->recv.bytes;
237    ServerStats.is_cti += CurrentTime - client_p->firsttime;
238  }
226    else
227      ++ServerStats.is_ni;
228  
# Line 251 | Line 238 | close_connection(struct Client *client_p
238    if (client_p->localClient->fd.flags.open)
239      fd_close(&client_p->localClient->fd);
240  
254  if (HasServlink(client_p))
255  {
256    if (client_p->localClient->ctrlfd.flags.open)
257      fd_close(&client_p->localClient->ctrlfd);
258  }
259
241    dbuf_clear(&client_p->localClient->buf_sendq);
242    dbuf_clear(&client_p->localClient->buf_recvq);
243    
# Line 307 | Line 288 | ssl_handshake(int fd, struct Client *cli
288   void
289   add_connection(struct Listener *listener, struct irc_ssaddr *irn, int fd)
290   {
291 <  struct Client *new_client;
311 <
312 <  assert(NULL != listener);
313 <
314 <  new_client = make_client(NULL);
291 >  struct Client *new_client = make_client(NULL);
292  
293    fd_open(&new_client->localClient->fd, fd, 1,
294            (listener->flags & LISTENER_SSL) ?
295            "Incoming SSL connection" : "Incoming connection");
296  
297 <  /*
297 >  /*
298     * copy address to 'sockhost' as a string, copy it to host too
299     * so we have something valid to put into error messages...
300     */
301    memcpy(&new_client->localClient->ip, irn, sizeof(struct irc_ssaddr));
302  
303 <  irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip,
304 <        new_client->localClient->ip.ss_len, new_client->sockhost,
305 <        sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST);
303 >  getnameinfo((struct sockaddr *)&new_client->localClient->ip,
304 >              new_client->localClient->ip.ss_len, new_client->sockhost,
305 >              sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST);
306    new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family;
307  
308 <  if (new_client->sockhost[0] == ':')
308 >  if (new_client->sockhost[0] == ':' && new_client->sockhost[1] == ':')
309    {
310      strlcpy(new_client->host, "0", sizeof(new_client->host));
311      strlcpy(new_client->host+1, new_client->sockhost, sizeof(new_client->host)-1);
312 +    memmove(new_client->sockhost+1, new_client->sockhost, sizeof(new_client->sockhost)-1);
313 +    new_client->sockhost[0] = '0';
314    }
315    else
316      strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host));
# Line 344 | Line 323 | add_connection(struct Listener *listener
323    {
324      if ((new_client->localClient->fd.ssl = SSL_new(ServerInfo.server_ctx)) == NULL)
325      {
326 <      ilog(L_CRIT, "SSL_new() ERROR! -- %s",
326 >      ilog(LOG_TYPE_IRCD, "SSL_new() ERROR! -- %s",
327             ERR_error_string(ERR_get_error(), NULL));
328  
329        SetDead(new_client);
# Line 521 | Line 500 | comm_connect_tcp(fde_t *fd, const char *
500  
501    snprintf(portname, sizeof(portname), "%d", port);
502  
503 <  if (irc_getaddrinfo(host, portname, &hints, &res))
503 >  if (getaddrinfo(host, portname, &hints, &res))
504    {
505      /* Send the DNS request, for the next level */
506      if (aftype == AF_INET6)
# Line 537 | Line 516 | comm_connect_tcp(fde_t *fd, const char *
516      memcpy(&fd->connect.hostaddr, res->ai_addr, res->ai_addrlen);
517      fd->connect.hostaddr.ss_len = res->ai_addrlen;
518      fd->connect.hostaddr.ss.ss_family = res->ai_family;
519 <    irc_freeaddrinfo(res);
519 >    freeaddrinfo(res);
520      comm_settimeout(fd, timeout*1000, comm_connect_timeout, NULL);
521      comm_connect_tryconnect(fd, NULL);
522    }

Diff Legend

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