Changeset 424 for trunk/wifidog/src/util.c
- Timestamp:
- 02/03/05 23:05:28 (8 years ago)
- Files:
-
- 1 modified
-
trunk/wifidog/src/util.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/src/util.c
r422 r424 51 51 52 52 static pthread_mutex_t ghbn_mutex = PTHREAD_MUTEX_INITIALIZER; 53 54 /* XXX Do these need to be locked ? */ 55 static time_t last_online_time = 0; 56 static time_t last_offline_time = 0; 53 57 54 58 /** Fork a child and execute a shell command, the parent … … 108 112 if (he == NULL) { 109 113 free(h_addr); 114 mark_offline(); 110 115 UNLOCK_GHBN(); 111 116 return NULL; 112 117 } 118 119 mark_online(); 113 120 114 121 in_addr_temp = (struct in_addr *)he->h_addr_list[0]; … … 145 152 return (char *)inet_ntoa(in); 146 153 } 154 155 void mark_online() { 156 time(&last_online_time); 157 } 158 159 void mark_offline() { 160 time(&last_offline_time); 161 } 162 163 int is_online() { 164 if (last_online_time == 0 || (last_offline_time - last_online_time) >= (config_get_config()->checkinterval * 2) ) { 165 /* We're probably offline */ 166 return (0); 167 } 168 else { 169 /* We're probably online */ 170 return (1); 171 } 172 } 173
