[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/icecream/icecream/daemon
From: Stephan Kulow <coolo () kde ! org>
Date: 2004-09-04 20:16:38
Message-ID: 20040904201638.82B0F1CF0 () office ! kde ! org
[Download RAW message or body]
CVS commit by coolo:
avoid a race between select and wait - loosing data on the road
M +25 -18 main.cpp 1.107
--- kdenonbeta/icecream/icecream/daemon/main.cpp #1.106:1.107
@@ -274,5 +274,5 @@ bool maybe_stats(bool force = false) {
myidleload += idleLoad * diff_stat;
- unsigned int realLoad = 1000 - myidleload / diff_sent;
+ unsigned int realLoad = diff_sent ? ( 1000 - myidleload / diff_sent ) : \
1000; msg.load = ( 700 * realLoad + 300 * memory_fillgrade ) / 1000;
if ( memory_fillgrade > 600 )
@@ -305,4 +305,22 @@ bool maybe_stats(bool force = false) {
}
+void fill_msg(int fd, JobDoneMsg *msg)
+{
+ read( fd, &msg->in_compressed, sizeof( unsigned int ) );
+ read( fd, &msg->in_uncompressed, sizeof( unsigned int ) );
+ read( fd, &msg->out_compressed, sizeof( unsigned int ) );
+ read( fd, &msg->out_uncompressed, sizeof( unsigned int ) );
+ read( fd, &msg->real_msec, sizeof( unsigned int ) );
+ if ( msg->out_uncompressed && !msg->in_uncompressed ) { // this is typical for \
client jobs + unsigned int job_id;
+ read( fd, &job_id, sizeof( unsigned int ) );
+ if ( job_id != msg->job_id )
+ log_error() << "the job ids for the client job do not match: " << job_id \
<< " " << msg->job_id << endl; + read( fd, &msg->user_msec, sizeof( unsigned \
int ) ); + read( fd, &msg->sys_msec, sizeof( unsigned int ) );
+ read( fd, &msg->pfaults, sizeof( unsigned int ) );
+ }
+}
+
int main( int argc, char ** argv )
{
@@ -603,6 +621,6 @@ int main( int argc, char ** argv )
// if the client compiles, we fork off right away
pid = fork();
- if ( pid == 0 ) {
-
+ if ( pid == 0 )
+ {
close( sockets[0] );
Msg *msg = req.second->get_msg(12 * 60); // wait forever
@@ -660,4 +678,5 @@ int main( int argc, char ** argv )
Pidmap::iterator pid_it = pidmap.find( child );
if ( pid_it != pidmap.end() ) {
+ fill_msg( pid_it->second, msg );
close( pid_it->second );
pidmap.erase( pid_it );
@@ -801,19 +820,7 @@ int main( int argc, char ** argv )
if ( FD_ISSET( it->second, &listen_set ) ) {
JobDoneMsg *msg = jobmap[it->first];
- if ( msg ) {
- read( it->second, &msg->in_compressed, sizeof( \
unsigned int ) );
- read( it->second, &msg->in_uncompressed, sizeof( \
unsigned int ) );
- read( it->second, &msg->out_compressed, sizeof( \
unsigned int ) );
- read( it->second, &msg->out_uncompressed, sizeof( \
unsigned int ) );
- read( it->second, &msg->real_msec, sizeof( unsigned \
int ) );
- if ( msg->out_uncompressed && !msg->in_uncompressed \
) { // this is typical for client jobs
- unsigned int job_id;
- read( it->second, &job_id, sizeof( unsigned int \
) );
- if ( job_id != msg->job_id )
- log_error() << "the job ids for the client \
job do not match: " << job_id << " " << msg->job_id << endl;
- read( it->second, &msg->user_msec, sizeof( \
unsigned int ) );
- read( it->second, &msg->sys_msec, sizeof( \
unsigned int ) );
- read( it->second, &msg->pfaults, sizeof( \
unsigned int ) );
- }
+ if ( msg )
+ {
+ fill_msg( it->second, msg );
close( it->second );
pidmap.erase( it );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic