| 1 | /** |
| 2 | * @file |
| 3 | * This file contains metaserver2 information - the metaserver2 |
| 4 | * implementation requires that a separate thread be used |
| 5 | * for updates, so a structure to get updated data to the thread |
| 6 | * is needed. |
| 7 | */ |
| 8 | |
| 9 | #ifndef METASERVER2_H |
| 10 | #define METASERVER2_H |
| 11 | |
| 12 | /* |
| 13 | * The current implementation of crossfire is not very thread |
| 14 | * friendly/safe - in fact, metaserver2 is the first part to |
| 15 | * use an extra thread. |
| 16 | * As such, it would be a lot of work to add the necessary |
| 17 | * locks in the rest of the code for the metaserver2 to be able |
| 18 | * to get the data it needs. So instead, we use this |
| 19 | * MS2UpdateInfo structure to get the data from the main thread |
| 20 | * to the metaserver thread - basically, the main thread |
| 21 | * gets a lock on the mutex, updates the fields in this structure |
| 22 | * and releases the lock. The metaserver2 thread will |
| 23 | * get a lock when it needs to get this information, copy |
| 24 | * it to the post form, then unlock the structure. |
| 25 | * In that way, neither side holds the lock very long, which is especially |
| 26 | * important because the metaserver2 thread could take quite a while |
| 27 | * to do its updates. |
| 28 | */ |
| 29 | |
| 30 | extern pthread_mutex_t ms2_info_mutex; |
| 31 | |
| 32 | /** Structure containing information sent to the metaserver2 */ |
| 33 | typedef struct _MetaServer2_UpdateInfo { |
| 34 | int num_players; /**< Number of players */ |
| 35 | int in_bytes; /**< Number of bytes received */ |
| 36 | int out_bytes; /**< Number of bytes sent */ |
| 37 | time_t uptime; /**< How long server has been up */ |
| 38 | } MetaServer2_UpdateInfo; |
| 39 | |
| 40 | extern MetaServer2_UpdateInfo metaserver2_updateinfo; |
| 41 | |
| 42 | #endif /* METASERVER2_H */ |