File: metaserver2.h

package info (click to toggle)
crossfire 1.75.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,168 kB
  • sloc: ansic: 83,169; sh: 4,659; perl: 1,736; lex: 1,443; makefile: 1,199; python: 43
file content (42 lines) | stat: -rw-r--r-- 1,619 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * @file
 * This file contains metaserver2 information - the metaserver2
 * implementation requires that a separate thread be used
 * for updates, so a structure to get updated data to the thread
 * is needed.
 */

#ifndef METASERVER2_H
#define METASERVER2_H

/*
 * The current implementation of crossfire is not very thread
 * friendly/safe - in fact, metaserver2 is the first part to
 * use an extra thread.
 * As such, it would be a lot of work to add the necessary
 * locks in the rest of the code for the metaserver2 to be able
 * to get the data it needs.  So instead, we use this
 * MS2UpdateInfo structure to get the data from the main thread
 * to the metaserver thread - basically, the main thread
 * gets a lock on the mutex, updates the fields in this structure
 * and releases the lock.  The metaserver2 thread will
 * get a lock when it needs to get this information, copy
 * it to the post form, then unlock the structure.
 * In that way, neither side holds the lock very long, which is especially
 * important because the metaserver2 thread could take quite a while
 * to do its updates.
 */

extern pthread_mutex_t ms2_info_mutex;

/** Structure containing information sent to the metaserver2 */
typedef struct _MetaServer2_UpdateInfo {
    int     num_players;        /**< Number of players */
    int     in_bytes;           /**< Number of bytes received */
    int     out_bytes;          /**< Number of bytes sent */
    time_t  uptime;             /**< How long server has been up */
} MetaServer2_UpdateInfo;

extern MetaServer2_UpdateInfo metaserver2_updateinfo;

#endif /* METASERVER2_H */