File Conn.c changed (mode: 100644) (index 912f76f..0c34f15) |
... |
... |
static void Conn_free_intern(const unsigned int slot) |
336 |
336 |
static int Conn_grow(void) |
static int Conn_grow(void) |
337 |
337 |
{ |
{ |
338 |
338 |
int ret; |
int ret; |
339 |
|
unsigned int alloc; |
|
|
339 |
|
unsigned int alloc, increment = 128; |
340 |
340 |
struct Conn *p, *set; |
struct Conn *p, *set; |
341 |
341 |
|
|
342 |
342 |
Log(10, "%s() Try to grow cells from %d to %d.\n", |
Log(10, "%s() Try to grow cells from %d to %d.\n", |
343 |
343 |
__FUNCTION__, |
__FUNCTION__, |
344 |
344 |
Conn_allocated, Conn_allocated + 128); |
Conn_allocated, Conn_allocated + 128); |
345 |
345 |
|
|
346 |
|
alloc = Conn_allocated + 128; |
|
|
346 |
|
alloc = Conn_allocated + increment; |
347 |
347 |
|
|
348 |
348 |
ret = Conn_engine_grow(alloc); |
ret = Conn_engine_grow(alloc); |
349 |
349 |
if (ret != 0) |
if (ret != 0) |
|
... |
... |
static int Conn_grow(void) |
353 |
353 |
if (p == NULL) |
if (p == NULL) |
354 |
354 |
return -1; |
return -1; |
355 |
355 |
|
|
|
356 |
|
Conn_mem_structs += increment * sizeof(struct Conn); |
|
357 |
|
|
356 |
358 |
set = p + Conn_allocated; |
set = p + Conn_allocated; |
357 |
|
memset(set, 0, 128 * sizeof(struct Conn)); |
|
|
359 |
|
memset(set, 0, increment * sizeof(struct Conn)); |
358 |
360 |
Conns = p; |
Conns = p; |
359 |
361 |
|
|
360 |
362 |
Conn_allocated = alloc; |
Conn_allocated = alloc; |
|
... |
... |
struct Conn *Conn_alloc(void) |
406 |
408 |
"Memory allocation error2!"); |
"Memory allocation error2!"); |
407 |
409 |
return NULL; |
return NULL; |
408 |
410 |
} |
} |
|
411 |
|
Conn_mem_buffers_in += Conn_default_ibuf - Conns[slot].ibuf_size; |
409 |
412 |
Conns[slot].ibuf = p; |
Conns[slot].ibuf = p; |
410 |
413 |
Conns[slot].ibuf_size = Conn_default_ibuf; |
Conns[slot].ibuf_size = Conn_default_ibuf; |
411 |
414 |
} |
} |
|
... |
... |
struct Conn *Conn_alloc(void) |
419 |
422 |
"Memory allocation error3!"); |
"Memory allocation error3!"); |
420 |
423 |
return NULL; |
return NULL; |
421 |
424 |
} |
} |
|
425 |
|
Conn_mem_buffers_out += Conn_default_obuf - Conns[slot].obuf_size; |
422 |
426 |
Conns[slot].obuf = p; |
Conns[slot].obuf = p; |
423 |
427 |
Conns[slot].obuf_size = Conn_default_obuf; |
Conns[slot].obuf_size = Conn_default_obuf; |
424 |
428 |
} |
} |
File Conn_engine_core.c changed (mode: 100644) (index 36c6828..e66be2f) |
... |
... |
struct timeval Conn_now; |
44 |
44 |
unsigned short Conn_level = 0; /* debug level */ |
unsigned short Conn_level = 0; /* debug level */ |
45 |
45 |
unsigned int Conn_accept_is_allowed; |
unsigned int Conn_accept_is_allowed; |
46 |
46 |
unsigned int Conn_accept_is_allowed_last; |
unsigned int Conn_accept_is_allowed_last; |
|
47 |
|
/* memory stuff */ |
|
48 |
|
unsigned long long Conn_mem_buffers_in = 0; |
|
49 |
|
unsigned long long Conn_mem_buffers_out = 0; |
|
50 |
|
unsigned long long Conn_mem_structs = 0; |
47 |
51 |
|
|
48 |
52 |
struct Conn *Conns = NULL; |
struct Conn *Conns = NULL; |
49 |
53 |
unsigned int Conn_inited = 0; |
unsigned int Conn_inited = 0; |
|
... |
... |
char *Conn_state(const struct Conn *C) |
273 |
277 |
* what = 0 for out buffer, what = 1 for input buffer |
* what = 0 for out buffer, what = 1 for input buffer |
274 |
278 |
* returns 0 if OK, -1 on error |
* returns 0 if OK, -1 on error |
275 |
279 |
*/ |
*/ |
276 |
|
int Conn_try_expand_buf(const unsigned int slot, const int what, const unsigned int needed) |
|
|
280 |
|
int Conn_try_expand_buf(const unsigned int slot, const int what, |
|
281 |
|
const unsigned int needed) |
277 |
282 |
{ |
{ |
278 |
283 |
char *p; |
char *p; |
279 |
284 |
unsigned int hm; |
unsigned int hm; |
|
... |
... |
int Conn_try_expand_buf(const unsigned int slot, const int what, const unsigned |
330 |
335 |
if (what == 0) { |
if (what == 0) { |
331 |
336 |
Conns[slot].obuf = p; |
Conns[slot].obuf = p; |
332 |
337 |
Conns[slot].obuf_size = hm; |
Conns[slot].obuf_size = hm; |
|
338 |
|
Conn_mem_buffers_out += hm - old_size; |
333 |
339 |
} else { |
} else { |
334 |
340 |
Conns[slot].ibuf = p; |
Conns[slot].ibuf = p; |
335 |
341 |
Conns[slot].ibuf_size = hm; |
Conns[slot].ibuf_size = hm; |
|
342 |
|
Conn_mem_buffers_in += hm - old_size; |
336 |
343 |
} |
} |
|
344 |
|
|
|
345 |
|
|
337 |
346 |
Log(10, "\tSucces. Old/new size = %u/%u.\n", |
Log(10, "\tSucces. Old/new size = %u/%u.\n", |
338 |
347 |
old_size, hm); |
old_size, hm); |
339 |
348 |
|
|
|
... |
... |
char *Conn_status(const unsigned int flags) |
579 |
588 |
/* TODO: "len += " is incorrect */ |
/* TODO: "len += " is incorrect */ |
580 |
589 |
tmp_len = snprintf(tmp, sizeof(tmp), |
tmp_len = snprintf(tmp, sizeof(tmp), |
581 |
590 |
"Conn_pending=%d Conn_no/Conn_max=%d/%d Conn_total=%lu" |
"Conn_pending=%d Conn_no/Conn_max=%d/%d Conn_total=%lu" |
582 |
|
" Conn_uptime=%lus Conn_allocated=%d Conn_work_to_do=%u\n", |
|
|
591 |
|
" Conn_uptime=%lus Conn_allocated=%d Conn_work_to_do=%u" |
|
592 |
|
" Conn_mem_structs=%llu Conn_mem_buffers_in/out=%llu/%llu\n", |
583 |
593 |
Conn_pending, Conn_no, Conn_max, Conn_total, |
Conn_pending, Conn_no, Conn_max, Conn_total, |
584 |
|
Conn_now.tv_sec - Conn_start, Conn_allocated, Conn_work_to_do); |
|
|
594 |
|
Conn_now.tv_sec - Conn_start, Conn_allocated, Conn_work_to_do, |
|
595 |
|
Conn_mem_structs, Conn_mem_buffers_in, Conn_mem_buffers_out); |
585 |
596 |
if (len + tmp_len < max) { |
if (len + tmp_len < max) { |
586 |
597 |
strcat(buf, tmp); |
strcat(buf, tmp); |
587 |
598 |
len += tmp_len; |
len += tmp_len; |
File Conn_engine_core.h changed (mode: 100644) (index f975897..b341afa) |
... |
... |
extern unsigned long Conn_total; |
236 |
236 |
extern unsigned int Conn_start; |
extern unsigned int Conn_start; |
237 |
237 |
extern unsigned int Conn_pending; |
extern unsigned int Conn_pending; |
238 |
238 |
extern struct timeval Conn_now; |
extern struct timeval Conn_now; |
|
239 |
|
extern unsigned long long Conn_mem_buffers_in; |
|
240 |
|
extern unsigned long long Conn_mem_buffers_out; |
|
241 |
|
extern unsigned long long Conn_mem_structs; |
239 |
242 |
|
|
240 |
243 |
extern unsigned int Conn_max_send; |
extern unsigned int Conn_max_send; |
241 |
244 |
extern unsigned int Conn_max_recv; |
extern unsigned int Conn_max_recv; |