r13944@catbus: nickm | 2007-07-27 15:52:35 -0400

Fix warnings on platforms where rlim values can be signed.
 Add an 8k buffer freelist.
 


svn:r10948
This commit is contained in:
Nick Mathewson 2007-07-27 19:53:29 +00:00
parent bc9a7be943
commit a5477c7bb9
2 changed files with 8 additions and 5 deletions

View File

@ -679,14 +679,14 @@ set_max_file_descriptors(unsigned long limit, unsigned long cap)
strerror(errno)); strerror(errno));
return -1; return -1;
} }
if (rlim.rlim_max < limit) { if ((unsigned long)rlim.rlim_max < limit) {
log_warn(LD_CONFIG,"We need %lu file descriptors available, and we're " log_warn(LD_CONFIG,"We need %lu file descriptors available, and we're "
"limited to %lu. Please change your ulimit -n.", "limited to %lu. Please change your ulimit -n.",
limit, (unsigned long)rlim.rlim_max); limit, (unsigned long)rlim.rlim_max);
return -1; return -1;
} }
most = (rlim.rlim_max > cap) ? cap : (unsigned) rlim.rlim_max; most = ((unsigned long)rlim.rlim_max > cap) ? cap : (unsigned) rlim.rlim_max;
if (most > rlim.rlim_cur) { if (most > (unsigned long)rlim.rlim_cur) {
log_info(LD_NET,"Raising max file descriptors from %lu to %lu.", log_info(LD_NET,"Raising max file descriptors from %lu to %lu.",
(unsigned long)rlim.rlim_cur, most); (unsigned long)rlim.rlim_cur, most);
} }

View File

@ -178,10 +178,11 @@ typedef struct free_mem_list_t {
/** Freelists to hold 4k and 16k memory chunks. This seems to be what /** Freelists to hold 4k and 16k memory chunks. This seems to be what
* we use most. */ * we use most. */
static free_mem_list_t free_mem_list_4k = { NULL, 0, 0, 4096, 16, INT_MAX }; static free_mem_list_t free_mem_list_4k = { NULL, 0, 0, 4096, 16, INT_MAX };
static free_mem_list_t free_mem_list_16k = { NULL, 0, 0, 16384, 4, 128 }; static free_mem_list_t free_mem_list_8k = { NULL, 0, 0, 8192 , 8, 128 };
static free_mem_list_t free_mem_list_16k = { NULL, 0, 0, 16384, 4, 64 };
/** Macro: True iff the size is one for which we keep a freelist. */ /** Macro: True iff the size is one for which we keep a freelist. */
#define IS_FREELIST_SIZE(sz) ((sz) == 4096 || (sz) == 16384) #define IS_FREELIST_SIZE(sz) ((sz) == 4096 || (sz) == 8192 || (sz) == 16384)
/** Return the proper freelist for chunks of size <b>sz</b>, or fail /** Return the proper freelist for chunks of size <b>sz</b>, or fail
* with an assertion. */ * with an assertion. */
@ -190,6 +191,8 @@ get_free_mem_list(size_t sz)
{ {
if (sz == 4096) { if (sz == 4096) {
return &free_mem_list_4k; return &free_mem_list_4k;
} else if (sz == 8192) {
return &free_mem_list_8k;
} else { } else {
tor_assert(sz == 16384); tor_assert(sz == 16384);
return &free_mem_list_16k; return &free_mem_list_16k;