static void *status_thread( void *arg )
{
+ int i;
page_status this = arg;
mvcp_notifier notifier = mvcp_get_notifier( this->status );
mvcp_status_t status;
+ mvcp_status_t *statuses;
show_units( this, TRUE );
-
+
+ statuses = malloc(sizeof(mvcp_status_t) * this->count);
+ memset(statuses, 0, sizeof(mvcp_status_t) * this->count);
+
while ( !this->terminated )
{
char buf[32];
- if ( !this->app->eof[this->app->selected_unit] &&
- mvcp_unit_get( this->app->command, this->app->selected_unit,
- "eof", buf, sizeof(buf) ) != -1)
- this->app->eof[this->app->selected_unit] = buf[0];
+ /* wait for any event from notifier */
+ mvcp_notifier_wait( notifier, &status );
- if ( mvcp_notifier_wait( notifier, &status ) != -1 )
+ /* get status for all units */
+ for(i = 0; i < this->count; i++)
{
+ mvcp_notifier_get( notifier, &status, i);
+
if ( status.status == unit_disconnected )
+ goto break_unit_disconnected;
+
+ if( memcmp(&status, &statuses[i], sizeof(mvcp_status_t)) || !this->app->eof[i])
{
- this->app->eof[this->app->selected_unit] = 0;
- break;
+ /* save status */
+ statuses[i] = status;
+
+ /* save eof status */
+ if ( !this->app->eof[i] && mvcp_unit_get( this->app->command, i,
+ "eof", buf, sizeof(buf) ) != -1)
+ this->app->eof[i] = buf[0];
+
+ /* send status update */
+ if ( show_status( this, &status ) )
+ show_units( this, TRUE );
}
- if ( show_status( this, &status ) )
- show_units( this, TRUE );
}
}
+break_unit_disconnected:
+
+ free(statuses);
+
show_units( this, FALSE );
if ( !this->terminated )