modbus/mb_runtime.c
changeset 4051 8816aee01b07
parent 4049 80fc760d4a4a
equal deleted inserted replaced
4050:b27df24a0ea8 4051:8816aee01b07
   686 		/* launch a thread to handle this client node timer */
   686 		/* launch a thread to handle this client node timer */
   687 		{
   687 		{
   688 			int res = 0;
   688 			int res = 0;
   689 			pthread_attr_t attr;
   689 			pthread_attr_t attr;
   690 			res |= pthread_attr_init(&attr);
   690 			res |= pthread_attr_init(&attr);
       
   691 #ifdef MODBUS_STACK_SIZE
       
   692 			res |= pthread_attr_setstacksize(&attr, MODBUS_STACK_SIZE);
       
   693 #endif
   691 			res |= pthread_create(&(client_nodes[index].timer_thread_id), &attr, &__mb_client_timer_thread, (void *)((char *)NULL + index));
   694 			res |= pthread_create(&(client_nodes[index].timer_thread_id), &attr, &__mb_client_timer_thread, (void *)((char *)NULL + index));
   692 			if (res !=  0) {
   695 			if (res !=  0) {
   693 				fprintf(stderr, "Modbus plugin: Error (%%d) starting timer thread for modbus client node %%s\n", res, client_nodes[index].location);
   696 				fprintf(stderr, "Modbus plugin: Error (%%d) starting timer thread for modbus client node %%s\n", res, client_nodes[index].location);
   694 				goto error_exit;
   697 				goto error_exit;
   695 			}
   698 			}
   699 		/* launch a thread to handle this client node */
   702 		/* launch a thread to handle this client node */
   700 		{
   703 		{
   701 			int res = 0;
   704 			int res = 0;
   702 			pthread_attr_t attr;
   705 			pthread_attr_t attr;
   703 			res |= pthread_attr_init(&attr);
   706 			res |= pthread_attr_init(&attr);
       
   707 #ifdef MODBUS_STACK_SIZE
       
   708 			res |= pthread_attr_setstacksize(&attr, MODBUS_STACK_SIZE);
       
   709 #endif
   704 			res |= pthread_create(&(client_nodes[index].thread_id), &attr, &__mb_client_thread, (void *)((char *)NULL + index));
   710 			res |= pthread_create(&(client_nodes[index].thread_id), &attr, &__mb_client_thread, (void *)((char *)NULL + index));
   705 			if (res !=  0) {
   711 			if (res !=  0) {
   706 				fprintf(stderr, "Modbus plugin: Error (%%d) starting thread for modbus client node %%s\n", res, client_nodes[index].location);
   712 				fprintf(stderr, "Modbus plugin: Error (%%d) starting thread for modbus client node %%s\n", res, client_nodes[index].location);
   707 				goto error_exit;
   713 				goto error_exit;
   708 			}
   714 			}
   726 		/* launch a thread to handle this server node */
   732 		/* launch a thread to handle this server node */
   727 		{
   733 		{
   728 			int res = 0;
   734 			int res = 0;
   729 			pthread_attr_t attr;
   735 			pthread_attr_t attr;
   730 			res |= pthread_attr_init(&attr);
   736 			res |= pthread_attr_init(&attr);
       
   737 #ifdef MODBUS_STACK_SIZE
       
   738 			res |= pthread_attr_setstacksize(&attr, MODBUS_STACK_SIZE);
       
   739 #endif
   731 			res |= pthread_create(&(server_nodes[index].thread_id), &attr, &__mb_server_thread, (void *)&(server_nodes[index]));
   740 			res |= pthread_create(&(server_nodes[index].thread_id), &attr, &__mb_server_thread, (void *)&(server_nodes[index]));
   732 			if (res !=  0) {
   741 			if (res !=  0) {
   733 				fprintf(stderr, "Modbus plugin: Error (%%d) starting modbus server thread for node %%s\n", res, server_nodes[index].location);
   742 				fprintf(stderr, "Modbus plugin: Error (%%d) starting modbus server thread for node %%s\n", res, server_nodes[index].location);
   734 				goto error_exit;
   743 				goto error_exit;
   735 			}
   744 			}