Hello. I came over something quite strange for me. In my program I have declared
Code:
map <int,int> client_map;
Simple. Then at some time I start a thread
Code:
pthread_t thread;
pthread_create(&thread,NULL,&main_login_thread,p);
main_login_thread is defined in another file and at the top there is
Code:
extern map <int,int> client_map;
Now, in main_login_thread, at some time I say
Code:
client_map[p->cl->sock]=p->cl->id_user;
only to find back in the program that client_map doesn't contain that.
Maybe this wouldn't sound so confusing, but that's just happening when I run with valgrind
Code:
valgrind --leak-check=yes --run-libc-freeres=no
When I run it without valgrind it just goes smooth. Another thing that I tried before this was to FD_SET a socket in an fd_set . And that doesn't work either. It just feels like working with different objects:|.
Can anyone help me? Thank you.
EDIT:
Now I see I was wrong about it not modifying client_map but FD_SET still doesn't work and I am pretty sure I am not screwing up anything.