mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
stratum: function to track mem usage
+ bad client possible leak... but it is not the main one
This commit is contained in:
parent
8c27bed438
commit
bd888ff4e2
3 changed files with 16 additions and 4 deletions
|
@ -639,7 +639,7 @@ void *client_thread(void *p)
|
|||
if (g_debuglog_client) {
|
||||
debuglog("client terminate\n");
|
||||
}
|
||||
if(!client || client->deleted) {
|
||||
if(!client) {
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
|
@ -657,13 +657,13 @@ void *client_thread(void *p)
|
|||
db_clear_worker(g_db, client);
|
||||
CommonUnlock(&g_db_mutex);
|
||||
}
|
||||
object_delete(client);
|
||||
} else {
|
||||
// only clients sockets in g_list_client are purged (if marked deleted)
|
||||
socket_close(client->sock);
|
||||
delete client;
|
||||
}
|
||||
|
||||
object_delete(client);
|
||||
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -679,13 +679,24 @@ int opened_files()
|
|||
int fds = 0;
|
||||
DIR *d = opendir("/proc/self/fd");
|
||||
if (d) {
|
||||
struct dirent *ent;
|
||||
while (readdir(d)) fds++;
|
||||
closedir(d);
|
||||
}
|
||||
return fds;
|
||||
}
|
||||
|
||||
int resident_size()
|
||||
{
|
||||
int sz, res = 0;
|
||||
FILE *fp = fopen("/proc/self/statm", "r");
|
||||
if (fp) {
|
||||
fscanf(fp,"%d", &sz);
|
||||
fscanf(fp,"%d", &res);
|
||||
fclose(fp);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void string_lower(char *s)
|
||||
{
|
||||
for(int i = 0; s[i]; i++)
|
||||
|
|
|
@ -103,6 +103,7 @@ long long current_timestamp();
|
|||
long long current_timestamp_dms();
|
||||
|
||||
int opened_files();
|
||||
int resident_size();
|
||||
|
||||
void string_lower(char *s);
|
||||
void string_upper(char *s);
|
||||
|
|
Loading…
Add table
Reference in a new issue