+2004-11-07 Michael Poole <mdpoole@troilus.org>
+
+ * acinclude.m4: Look for a 64-bit integer type.
+
+ * configure.in: Look for inttypes.h, since some systems have that
+ but not stdint.h (and define 64-bit integers therein).
+
+ * include/client.h: Delete con_sendK, con_receiveK. Make
+ con_sendB and con_receiveB 64 bits wide.
+
+ * include/s_misc.h: Delete is_cks, is_ckr, is_sks, is_skr.
+ Convert the other byte counters and the connected time counters to
+ 64 bits wide.
+
+ * ircd/ircd_snprintf.c (doprintf): Unconditionalize the
+ HAVE_LONG_LONG bits, and use the 64-bit integer types from above.
+
+ * ircd/packet.c (update_bytes_received): Remove use of
+ cli_receiveK().
+
+ * ircd/s_bsd.c (deliver_it): Likewise.
+ (close_connection): Likewise.
+
+ * ircd/s_misc.c (tstats): Likewise. Update format strings to use
+ %Lu for 64-bit integer parameters.
+
+ * ircd/s_stats (stats_links): Convert cli_sendK() and
+ cli_receiveK() use shifted versions of the byte counters, and
+ update format strings to use %Lu for 64-bit integer parameters.
+
2004-11-07 Michael Poole <mdpoole@troilus.org>
* include/s_user.h (add_silence): Delete.
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void *)
+AC_CHECK_SIZEOF(int64_t)
+AC_CHECK_SIZEOF(long long)
if test "$ac_cv_sizeof_int" = 2 ; then
AC_CHECK_TYPE(int16_t, int)
AC_CHECK_TYPE(uint16_t, unsigned int)
AC_CHECK_TYPE(uint32_t, unsigned long)
else
AC_MSG_ERROR([Cannot find a type with size of 32 bits])
+fi
+if test "$ac_cv_sizeof_int64_t" = 8 ; then
+ AC_CHECK_TYPE(int64_t)
+ AC_CHECK_TYPE(uint64_t)
+elif test "$ac_cv_sizeof_long_long" = 8 ; then
+ AC_CHECK_TYPE(int64_t, long long)
+ AC_CHECK_TYPE(uint64_t, unsigned long long)
+else
+ AC_MSG_ERROR([Cannot find a type with size of 64 bits])
fi])
dnl Written by John Hawkinson <jhawk@mit.edu>. This code is in the Public
dnl Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS(crypt.h poll.h stdint.h sys/devpoll.h sys/epoll.h sys/event.h sys/param.h sys/socket.h)
+AC_CHECK_HEADERS(crypt.h poll.h inttypes.h stdint.h sys/devpoll.h sys/epoll.h sys/event.h sys/param.h sys/socket.h)
dnl Checks for typedefs, structures, and compiler characteristics
dnl AC_C_CONST
struct MsgQ con_sendQ; /**< Outgoing message queue */
struct DBuf con_recvQ; /**< Incoming data yet to be parsed */
unsigned int con_sendM; /**< Stats: protocol messages sent */
- unsigned int con_sendK; /**< Stats: total k-bytes sent */
unsigned int con_receiveM; /**< Stats: protocol messages received */
- unsigned int con_receiveK; /**< Stats: total k-bytes received */
- unsigned short con_sendB; /**< Bytes sent, mod 1024. */
- unsigned short con_receiveB; /**< Bytes received, mod 1024. */
+ uint64_t con_sendB; /**< Bytes sent. */
+ uint64_t con_receiveB; /**< Bytes received. */
struct Listener* con_listener; /**< Listening socket which we accepted
from. */
struct SLink* con_confs; /**< Associated configuration records. */
#define cli_recvQ(cli) con_recvQ(cli_connect(cli))
/** Get count of messages sent to client. */
#define cli_sendM(cli) con_sendM(cli_connect(cli))
-/** Get number of kilobytes sent to client. */
-#define cli_sendK(cli) con_sendK(cli_connect(cli))
/** Get number of messages received from client. */
#define cli_receiveM(cli) con_receiveM(cli_connect(cli))
-/** Get number of kilobytes received from client. */
-#define cli_receiveK(cli) con_receiveK(cli_connect(cli))
/** Get number of bytes (modulo 1024) sent to client. */
#define cli_sendB(cli) con_sendB(cli_connect(cli))
/** Get number of bytes (modulo 1024) received from client. */
#define con_recvQ(con) ((con)->con_recvQ)
/** Get number of messages sent to connection. */
#define con_sendM(con) ((con)->con_sendM)
-/** Get number of kilobytes sent to connection. */
-#define con_sendK(con) ((con)->con_sendK)
/** Get number of messages received from connection. */
#define con_receiveM(con) ((con)->con_receiveM)
-/** Get number of kilobytes received from connection. */
-#define con_receiveK(con) ((con)->con_receiveK)
/** Get number of bytes (modulo 1024) sent to connection. */
#define con_sendB(con) ((con)->con_sendB)
/** Get number of bytes (modulo 1024) received from connection. */
* Structures
*/
+#ifdef HAVE_INTTYPES_H
+# ifndef INCLUDED_inttypes_h
+# include <inttypes.h>
+# define INCLUDED_inttypes_h
+# endif
+#else
+# ifdef HAVE_STDINT_H
+# ifndef INCLUDED_stdint_h
+# include <stdint.h>
+# define INCLUDED_stdint_h
+# endif
+# endif
+#endif
+
/** Structure used to count many server-wide statistics. */
struct ServerStatistics {
unsigned int is_cl; /**< number of client connections */
unsigned int is_sv; /**< number of server connections */
unsigned int is_ni; /**< connection but no idea who it was */
- unsigned short int is_cbs; /**< bytes sent to clients */
- unsigned short int is_cbr; /**< bytes received to clients */
- unsigned short int is_sbs; /**< bytes sent to servers */
- unsigned short int is_sbr; /**< bytes received to servers */
- unsigned int is_cks; /**< k-bytes sent to clients */
- unsigned int is_ckr; /**< k-bytes received to clients */
- unsigned int is_sks; /**< k-bytes sent to servers */
- unsigned int is_skr; /**< k-bytes received to servers */
- time_t is_cti; /**< time spent connected by clients */
- time_t is_sti; /**< time spent connected by servers */
+ uint64_t is_cbs; /**< bytes sent to clients */
+ uint64_t is_cbr; /**< bytes received to clients */
+ uint64_t is_sbs; /**< bytes sent to servers */
+ uint64_t is_sbr; /**< bytes received to servers */
+ uint64_t is_cti; /**< time spent connected by clients */
+ uint64_t is_sti; /**< time spent connected by servers */
unsigned int is_ac; /**< connections accepted */
unsigned int is_ref; /**< accepts refused */
unsigned int is_unco; /**< unknown commands */
*((char *)va_arg(vp, int *)) = TOTAL(buf_p);
else if (fld_s.flags & TYPE_SHORT) /* eg, %hn */
*((short *)va_arg(vp, int *)) = TOTAL(buf_p);
-#ifdef HAVE_LONG_LONG
else if (fld_s.flags & TYPE_QUAD) /* eg, %qn */
- *((my_quad_t *)va_arg(vp, my_quad_t *)) = TOTAL(buf_p);
-#endif /* HAVE_LONG_LONG */
+ *((int64_t *)va_arg(vp, int64_t *)) = TOTAL(buf_p);
else if (fld_s.flags & TYPE_LONG) /* eg, %ln */
*((long *)va_arg(vp, long *)) = TOTAL(buf_p);
else if (fld_s.flags & TYPE_INTMAX) /* eg, %jn */
fld_s.value.v_int = (unsigned char)va_arg(vp, unsigned int);
else if (fld_s.flags & TYPE_SHORT) /* eg, %hu */
fld_s.value.v_int = (short)va_arg(vp, unsigned int);
-#ifdef HAVE_LONG_LONG
else if (fld_s.flags & TYPE_QUAD) /* eg, %qu */
- fld_s.value.v_int = va_arg(vp, _large_t);
-#endif
+ fld_s.value.v_int = va_arg(vp, uint64_t);
else if (fld_s.flags & TYPE_LONG) /* eg, %lu */
fld_s.value.v_int = va_arg(vp, unsigned long);
else if (fld_s.flags & TYPE_INTMAX) /* eg, %ju */
signed_int = (char)va_arg(vp, unsigned int);
else if (fld_s.flags & TYPE_SHORT) /* eg, %hd */
signed_int = (short)va_arg(vp, unsigned int);
-#ifdef HAVE_LONG_LONG
else if (fld_s.flags & TYPE_QUAD) /* eg, %qd */
- signed_int = va_arg(vp, _large_t);
-#endif
+ signed_int = va_arg(vp, int64_t);
else if (fld_s.flags & TYPE_LONG) /* eg, %ld */
signed_int = va_arg(vp, long);
else if (fld_s.flags & TYPE_INTMAX) /* eg, %jd */
{
cli_receiveB(&me) += length; /* Update bytes received */
cli_receiveB(cptr) += length;
-
- if (cli_receiveB(cptr) > 1023) {
- cli_receiveK(cptr) += (cli_receiveB(cptr) >> 10);
- cli_receiveB(cptr) &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
- }
- if (cli_receiveB(&me) > 1023) {
- cli_receiveK(&me) += (cli_receiveB(&me) >> 10);
- cli_receiveB(&me) &= 0x03ff;
- }
}
/** Add one message to a client's received statistics.
cli_sendB(cptr) += bytes_written;
cli_sendB(&me) += bytes_written;
- if (cli_sendB(cptr) > 1023) {
- cli_sendK(cptr) += (cli_sendB(cptr) >> 10);
- cli_sendB(cptr) &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
- }
- if (cli_sendB(&me) > 1023) {
- cli_sendK(&me) += (cli_sendB(&me) >> 10);
- cli_sendB(&me) &= 0x03ff;
- }
- /*
- * XXX - hrmm.. set blocked here? the socket didn't
- * say it was blocked
- */
+ /* A partial write implies that future writes will block. */
if (bytes_written < bytes_count)
SetFlag(cptr, FLAG_BLOCKED);
break;
ServerStats->is_sv++;
ServerStats->is_sbs += cli_sendB(cptr);
ServerStats->is_sbr += cli_receiveB(cptr);
- ServerStats->is_sks += cli_sendK(cptr);
- ServerStats->is_skr += cli_receiveK(cptr);
ServerStats->is_sti += CurrentTime - cli_firsttime(cptr);
- if (ServerStats->is_sbs > 1023) {
- ServerStats->is_sks += (ServerStats->is_sbs >> 10);
- ServerStats->is_sbs &= 0x3ff;
- }
- if (ServerStats->is_sbr > 1023) {
- ServerStats->is_skr += (ServerStats->is_sbr >> 10);
- ServerStats->is_sbr &= 0x3ff;
- }
/*
* If the connection has been up for a long amount of time, schedule
* a 'quick' reconnect, else reset the next-connect cycle.
ServerStats->is_cl++;
ServerStats->is_cbs += cli_sendB(cptr);
ServerStats->is_cbr += cli_receiveB(cptr);
- ServerStats->is_cks += cli_sendK(cptr);
- ServerStats->is_ckr += cli_receiveK(cptr);
ServerStats->is_cti += CurrentTime - cli_firsttime(cptr);
- if (ServerStats->is_cbs > 1023) {
- ServerStats->is_cks += (ServerStats->is_cbs >> 10);
- ServerStats->is_cbs &= 0x3ff;
- }
- if (ServerStats->is_cbr > 1023) {
- ServerStats->is_ckr += (ServerStats->is_cbr >> 10);
- ServerStats->is_cbr &= 0x3ff;
- }
}
else
ServerStats->is_ni++;
{
sp->is_sbs += cli_sendB(acptr);
sp->is_sbr += cli_receiveB(acptr);
- sp->is_sks += cli_sendK(acptr);
- sp->is_skr += cli_receiveK(acptr);
sp->is_sti += CurrentTime - cli_firsttime(acptr);
sp->is_sv++;
- if (sp->is_sbs > 1023)
- {
- sp->is_sks += (sp->is_sbs >> 10);
- sp->is_sbs &= 0x3ff;
- }
- if (sp->is_sbr > 1023)
- {
- sp->is_skr += (sp->is_sbr >> 10);
- sp->is_sbr &= 0x3ff;
- }
}
else if (IsUser(acptr))
{
sp->is_cbs += cli_sendB(acptr);
sp->is_cbr += cli_receiveB(acptr);
- sp->is_cks += cli_sendK(acptr);
- sp->is_ckr += cli_receiveK(acptr);
sp->is_cti += CurrentTime - cli_firsttime(acptr);
sp->is_cl++;
- if (sp->is_cbs > 1023)
- {
- sp->is_cks += (sp->is_cbs >> 10);
- sp->is_cbs &= 0x3ff;
- }
- if (sp->is_cbr > 1023)
- {
- sp->is_ckr += (sp->is_cbr >> 10);
- sp->is_cbr &= 0x3ff;
- }
}
else if (IsUnknown(acptr))
sp->is_ni++;
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Client server");
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":connected %u %u",
sp->is_cl, sp->is_sv);
- send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":bytes sent %u.%uK %u.%uK",
- sp->is_cks, sp->is_cbs, sp->is_sks, sp->is_sbs);
- send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":bytes recv %u.%uK %u.%uK",
- sp->is_ckr, sp->is_cbr, sp->is_skr, sp->is_sbr);
- send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":time connected %Tu %Tu",
+ send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":bytes sent %Lu %Lu",
+ sp->is_cbs, sp->is_sbs);
+ send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":bytes recv %Lu %Lu",
+ sp->is_cbr, sp->is_sbr);
+ send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":time connected %Lu %Lu",
sp->is_cti, sp->is_sti);
}
if (!(!name || wilds) && 0 != ircd_strcmp(name, cli_name(acptr)))
continue;
send_reply(sptr, SND_EXPLICIT | RPL_STATSLINKINFO,
- "%s %u %u %u %u %u :%Tu",
+ "%s %u %u %Lu %u %Lu :%Tu",
(*(cli_name(acptr))) ? cli_name(acptr) : "<unregistered>",
(int)MsgQLength(&(cli_sendQ(acptr))), (int)cli_sendM(acptr),
- (int)cli_sendK(acptr), (int)cli_receiveM(acptr),
- (int)cli_receiveK(acptr), CurrentTime - cli_firsttime(acptr));
+ (cli_sendB(acptr) >> 10), (int)cli_receiveM(acptr),
+ (cli_receiveB(acptr) >> 10), CurrentTime - cli_firsttime(acptr));
}
}