Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ static void icerun_show_usage()
"\n");
}

static int get_niceness()
{
errno = 0;
int niceness = getpriority( PRIO_PROCESS, getpid());
if( niceness == -1 && errno != 0 )
niceness = 0;
return niceness;
}

volatile bool local = false;

static void dcc_client_signalled(int whichsig)
Expand Down Expand Up @@ -591,7 +600,7 @@ int main(int argc, char **argv)
Msg *startme = nullptr;

/* Inform the daemon that we like to start a job. */
if (local_daemon->send_msg(JobLocalBeginMsg(0, get_absfilename(job.outputFile()),fulljob))) {
if (local_daemon->send_msg(JobLocalBeginMsg(0, get_absfilename(job.outputFile()),fulljob,get_niceness()))) {
/* Now wait until the daemon gives us the start signal. 40 minutes
should be enough for all normal compile or link jobs, but with expensive jobs
(which fulljobs may likely be, e.g. LTO linking) use an even larger timeout. */
Expand Down
1 change: 1 addition & 0 deletions daemon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,7 @@ bool Daemon::handle_local_job(Client *client, Msg *msg)
{
JobLocalBeginMsg* m = dynamic_cast<JobLocalBeginMsg *>(msg);
client->status = Client::LINKJOB;
client->niceness = m->niceness;
client->outfile = m->outfile;
client->fulljob = m->fulljob;
return true;
Expand Down
6 changes: 6 additions & 0 deletions services/comm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,9 @@ void JobLocalBeginMsg::fill_from_channel(MsgChannel *c)
*c >> full;
fulljob = full;
}
if (IS_PROTOCOL_VERSION(45, c)) {
*c >> niceness;
}
}

void JobLocalBeginMsg::send_to_channel(MsgChannel *c) const
Expand All @@ -2297,6 +2300,9 @@ void JobLocalBeginMsg::send_to_channel(MsgChannel *c) const
if (IS_PROTOCOL_VERSION(44, c)) {
*c << (uint32_t) fulljob;
}
if (IS_PROTOCOL_VERSION(45, c)) {
*c << niceness;
}
}

void JobLocalDoneMsg::fill_from_channel(MsgChannel *c)
Expand Down
8 changes: 5 additions & 3 deletions services/comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "job.h"

// if you increase the PROTOCOL_VERSION, add a macro below and use that
#define PROTOCOL_VERSION 44
#define PROTOCOL_VERSION 45
// if you increase the MIN_PROTOCOL_VERSION, comment out macros below and clean up the code
#define MIN_PROTOCOL_VERSION 21

Expand Down Expand Up @@ -740,12 +740,13 @@ class JobDoneMsg : public Msg
class JobLocalBeginMsg : public Msg
{
public:
JobLocalBeginMsg(int job_id = 0, const std::string &file = "", bool full = false)
JobLocalBeginMsg(int job_id = 0, const std::string &file = "", bool full = false, uint32_t _niceness = 0)
: Msg(Msg::JOB_LOCAL_BEGIN)
, outfile(file)
, stime(time(0))
, id(job_id)
, fulljob(full) {}
, fulljob(full)
, niceness(_niceness) {}

virtual void fill_from_channel(MsgChannel *c);
virtual void send_to_channel(MsgChannel *c) const;
Expand All @@ -754,6 +755,7 @@ class JobLocalBeginMsg : public Msg
uint32_t stime;
uint32_t id;
bool fulljob;
uint32_t niceness; // nice priority (0-20)
};

class JobLocalDoneMsg : public Msg
Expand Down