Project

General

Profile

Revision 1063

added some error checking

View differences:

branches/simulator/projects/simulator/simulator/core/robot.c
245 245
void* robot_event_loop(void* arg)
246 246
{
247 247
	int i;
248
	//TODO: errors
248
	int ret;
249 249

  
250
	//TODO: not exit if there is an error?
251

  
250 252
	while (1)
251 253
	{
252
		pthread_mutex_lock(&all_finished_mutex);
254
		ret = pthread_mutex_lock(&all_finished_mutex);
255
		if(ret)
256
		  err(errno, "error locking mutex in even loop");
253 257
		// TODO: race condition for adding robots?
254 258
		if (finished < num_robots)
255 259
		{
256
			pthread_cond_wait(&all_finished_cond, &all_finished_mutex);
260
			ret = pthread_cond_wait(&all_finished_cond, &all_finished_mutex);
261
			if(ret)
262
			  err(errno, "error waiting on condition variable");
257 263
		}
258 264
		finished = 0;
259
		pthread_mutex_unlock(&all_finished_mutex);
265

  
266
		ret = pthread_mutex_unlock(&all_finished_mutex);
267
		if(ret)
268
		  fprintf(stderr, "hmmm, error unlocking. errno: %d", errno);
269

  
260 270
		for (i = 0; i < robots_size; i++)
261 271
			if (robots[i].id != -1)
262 272
				robot_update(i);
273

  
263 274
		for (i = 0; i < robots_size; i++)
264 275
		{
265 276
			if (robots[i].id == -1)
266 277
				continue;
267
			kill(robots[i].pid, SIGCONT);
278
			ret = kill(robots[i].pid, SIGCONT);
279
			if(ret)
280
			  warn("error: could not kill resume robot proc.");
268 281
		}
269 282

  
270 283
		gui_refresh();

Also available in: Unified diff