X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fsharedmemory.c;h=46cdc45340a22857dc06d0b104c921b394ef90b7;hb=38d77b3cbee831144dcfdb2b79c93bc6d494f7fe;hp=6af3f752fe3c057c0e074d0261c739be0b97ee99;hpb=1fbc5db2d0c6168e10b116cb474174d165192530;p=umurmur.git diff --git a/src/sharedmemory.c b/src/sharedmemory.c index 6af3f75..46cdc45 100644 --- a/src/sharedmemory.c +++ b/src/sharedmemory.c @@ -4,13 +4,13 @@ void Sharedmemory_init(void) { - int bindport = getIntConf(BINDPORT); //MJP BUG commandline option for address and port dont work this way going to have + int bindport = getIntConf(BINDPORT); //MJP BUG commandline option for address and port dont work this way going to have int server_max_clients = getIntConf(MAX_CLIENTS); //to bring them across as prameters to Sharedmemory_init(void) int shmptr_size = sizeof( shm_t ) + (sizeof( shmclient_t ) * server_max_clients); - sprintf( shm_file_name, "umurmurd:%i", bindport ); + sprintf( shm_file_name, "umurmurd:%i", bindport ); Log_info("SHM_FD: %s", shm_file_name ); @@ -29,14 +29,14 @@ if( ftruncate( shm_fd, shmptr_size ) == -1 ) shmptr = mmap(0, shmptr_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); if (shmptr == (void *) -1) - { + { fprintf(stderr, "mmap failed : %s\n", strerror(errno)); //MJP BUG make this Log_ calls once I get this working exit(1); } memset( shmptr, 0, shmptr_size ); - + shmptr->umurmurd_pid = getpid(); shmptr->server_max_clients = server_max_clients; } @@ -47,11 +47,7 @@ void Sharedmemory_update(void) uint64_t now; unsigned int cc = 0; client_t *client_itr = NULL; - static size_t bt_end = sizeof( bool_t ) * 8, //compute once - pa_end = sizeof( float ) * 4, - pc_end = sizeof( uint32_t ) * 2; - - + memset( &shmptr->client[0], 0, sizeof( shmclient_t ) * shmptr->server_max_clients ); shmptr->clientcount = Client_count(); @@ -66,16 +62,40 @@ void Sharedmemory_update(void) strncpy( shmptr->client[cc].username, client_itr->username, 120 ); strncpy( shmptr->client[cc].ipaddress, Util_clientAddressToString( client_itr ), 45 ); - shmptr->client[cc].tcp_port = Util_clientAddressToPortTCP( client_itr ); - shmptr->client[cc].udp_port = Util_clientAddressToPortUDP( client_itr ); strncpy( shmptr->client[cc].channel, channel->name, 120 ); + + strncpy( shmptr->client[cc].os, client_itr->os, 120 ); + strncpy( shmptr->client[cc].release, client_itr->release, 120 ); + strncpy( shmptr->client[cc].os_version, client_itr->os_version, 120 ); + + shmptr->client[cc].tcp_port = Util_clientAddressToPortTCP( client_itr ); + shmptr->client[cc].udp_port = Util_clientAddressToPortUDP( client_itr ); shmptr->client[cc].online_secs = ( now - client_itr->connectTime ) / 1000000LL; shmptr->client[cc].idle_secs = ( now - client_itr->idleTime ) / 1000000LL; - - memcpy( &shmptr->client[cc].bUDP, &client_itr->bUDP, bt_end ); - memcpy( &shmptr->client[cc].UDPPingAvg, &client_itr->UDPPingAvg, pa_end ); - memcpy( &shmptr->client[cc].UDPPackets, &client_itr->UDPPackets, pc_end ); + + shmptr->client[cc].bUDP = client_itr->bUDP; + shmptr->client[cc].deaf = client_itr->deaf; + shmptr->client[cc].mute = client_itr->mute; + shmptr->client[cc].bOpus = client_itr->bOpus; + shmptr->client[cc].self_deaf = client_itr->self_deaf; + shmptr->client[cc].self_mute = client_itr->self_mute; + shmptr->client[cc].recording = client_itr->recording; + shmptr->client[cc].authenticated = client_itr->authenticated; + + shmptr->client[cc].availableBandwidth = client_itr->availableBandwidth; + + shmptr->client[cc].UDPPingAvg = client_itr->UDPPingAvg; + shmptr->client[cc].UDPPingVar = client_itr->UDPPingVar; + shmptr->client[cc].TCPPingAvg = client_itr->TCPPingAvg; + shmptr->client[cc].TCPPingVar = client_itr->TCPPingVar; + + shmptr->client[cc].isAdmin = client_itr->isAdmin; + shmptr->client[cc].isSuppressed = client_itr->isSuppressed; + + shmptr->client[cc].UDPPackets = client_itr->UDPPackets; + shmptr->client[cc].TCPPackets = client_itr->TCPPackets; + } cc++; }