This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Here's the patch I promised. The cast from (struct __sockaddr_in *) to (struct sockaddr_in *) in res_nsend should be kosher. Only the members that are present in both structures are referenced in sock_eq. The size of `_res' is now back to 512 bytes on the x86. The other 32-bit systems are probably also OK. I'm not so sure about the 64-bit systems though. I think everything should fit exactly into the 72 bytes padding at the end of the glibc 2.1 `struct __res_state'. We might need to adjust the size of the padding in the glibc 2.2 _res._u union though. Could the alpha and sparc64 maintainers check please. Mark 2000-07-20 Mark Kettenis <kettenis@gnu.org> Fix problems with `struct __res_state' getting too big. * resolv/resolv.h (struct __sockaddr_in): New definition. (struct __res_state): Use __sockaddr_in instead of sockaddr_in in the private parts of the structure to save some space. * resolv/res_send.c (res_nsend): Cast &EXT(statp).nsaddrs[ns] to (struct sockaddr_in *) in call to sock_eq. Use memcpy to copy statp->nsaddr_list[ns] to &EXT(statp).nsaddrs[ns]. Index: resolv/resolv.h =================================================================== RCS file: /cvs/glibc/libc/resolv/resolv.h,v retrieving revision 1.26 diff -u -p -r1.26 resolv.h --- resolv/resolv.h 2000/07/19 22:02:37 1.26 +++ resolv/resolv.h 2000/07/20 18:52:25 @@ -123,6 +123,16 @@ struct res_sym { #define RES_DFLRETRY 2 /* Default #/tries. */ #define RES_MAXTIME 65535 /* Infinity, in milliseconds. */ +/* + * Like "struct sockaddr_in", but without any padding (to avoid making + * "struct __rest_state" too large). + */ +struct __sockaddr_in { + __SOCKADDR_COMMON (sin_); + in_port_t sin_port; + struct in_addr sin_addr; +}; + struct __res_state { int retrans; /* retransmition time interval */ int retry; /* number of times to retransmit */ @@ -153,7 +163,7 @@ struct __res_state { u_int16_t nscount; u_int16_t nstimes[MAXNS]; /* ms. */ int nssocks[MAXNS]; - struct sockaddr_in nsaddrs[MAXNS]; + struct __sockaddr_in nsaddrs[MAXNS]; } _ext; } _u; }; Index: resolv/res_send.c =================================================================== RCS file: /cvs/glibc/libc/resolv/res_send.c,v retrieving revision 1.26 diff -u -p -r1.26 res_send.c --- resolv/res_send.c 2000/07/19 22:02:19 1.26 +++ resolv/res_send.c 2000/07/20 18:52:25 @@ -361,6 +361,9 @@ res_nsend(res_state statp, else for (ns = 0; ns < statp->nscount; ns++) if (!sock_eq(&statp->nsaddr_list[ns], +#ifdef _LIBC + (struct sockaddr_in *) +#endif &EXT(statp).nsaddrs[ns])) { needclose++; break; @@ -374,7 +377,13 @@ res_nsend(res_state statp, */ if (EXT(statp).nscount == 0) { for (ns = 0; ns < statp->nscount; ns++) { +#ifdef _LIBC + memcpy(&EXT(statp).nsaddrs[ns], + &statp->nsaddr_list[ns], + sizeof (&EXT(statp).nsaddrs[0])); +#else EXT(statp).nsaddrs[ns] = statp->nsaddr_list[ns]; +#endif EXT(statp).nstimes[ns] = RES_MAXTIME; EXT(statp).nssocks[ns] = -1; }
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |