mirror of https://github.com/BOINC/boinc.git
- client: small tweak to work fetch:
if project has crazy DCF, don't automatically request 1 sec; only request work if there's a shortfall. - intermediate checkin for notices stuff svn path=/trunk/boinc/; revision=20145
This commit is contained in:
parent
4642a65f39
commit
ee343cea02
|
@ -345,3 +345,23 @@ David 12 Jan 2010
|
|||
AdvancedFrame.cpp
|
||||
Makefile.am
|
||||
ViewNotifications* -> ViewNotices*
|
||||
|
||||
David 12 Jan 2010
|
||||
- client: small tweak to work fetch:
|
||||
if project has crazy DCF, don't automatically request 1 sec;
|
||||
only request work if there's a shortfall.
|
||||
- intermediate checkin for notices stuff
|
||||
|
||||
client/
|
||||
Makefile.am
|
||||
work_fetch.cpp
|
||||
html/
|
||||
inc/
|
||||
forum_rss.inc
|
||||
notify.inc
|
||||
pm.inc
|
||||
user/
|
||||
notices.php (new)
|
||||
sched
|
||||
handle_request.cpp
|
||||
sched_types.cpp,h
|
||||
|
|
|
@ -85,6 +85,8 @@ boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD
|
|||
boinc_clientdir = $(bindir)
|
||||
|
||||
switcher_SOURCES = switcher.cpp
|
||||
switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib
|
||||
switcher_LDADD = $(LIBBOINC)
|
||||
|
||||
## since we are using libtool we need some magic to get boinc and boinc_client
|
||||
## to both be installed properly. The next two rules do that...
|
||||
|
|
|
@ -332,20 +332,23 @@ PROJECT* RSC_WORK_FETCH::choose_project(int criterion) {
|
|||
return pbest;
|
||||
}
|
||||
|
||||
// request this project's share of shortfall and instances
|
||||
// request this project's share of shortfall and instances.
|
||||
// don't request anything if project is overworked or backed off.
|
||||
//
|
||||
void RSC_WORK_FETCH::set_request(PROJECT* p) {
|
||||
RSC_PROJECT_WORK_FETCH& w = project_state(p);
|
||||
if (!w.may_have_work) return;
|
||||
if (w.overworked()) return;
|
||||
double dcf = p->duration_correction_factor;
|
||||
if (dcf < 0.02 || dcf > 80.0) {
|
||||
// if project's DCF is too big or small,
|
||||
// its completion time estimates are useless; just ask for 1 second
|
||||
//
|
||||
req_secs = 1;
|
||||
} else {
|
||||
req_secs = shortfall * w.fetchable_share;
|
||||
if (shortfall) {
|
||||
double dcf = p->duration_correction_factor;
|
||||
if (dcf < 0.02 || dcf > 80.0) {
|
||||
// if project's DCF is too big or small,
|
||||
// its completion time estimates are useless; just ask for 1 second
|
||||
//
|
||||
req_secs = 1;
|
||||
} else {
|
||||
req_secs = shortfall * w.fetchable_share;
|
||||
}
|
||||
}
|
||||
|
||||
// the number of additional instances needed to have our share
|
||||
|
|
|
@ -22,6 +22,35 @@ require_once("../inc/util.inc");
|
|||
require_once("../inc/text_transform.inc");
|
||||
require_once("../project/project.inc");
|
||||
|
||||
function show_forum_rss_item($thread, $userid, $threads_only, $truncate) {
|
||||
$unique_url=URL_BASE."forum_thread.php?id=".$thread->id;
|
||||
|
||||
$clause2 = " and hidden=0 ";
|
||||
if ($userid) $clause2 .= "and user=$userid";
|
||||
if ($threads_only) {
|
||||
$posts = BoincPost::enum("thread=$thread->id $clause2 order by id limit 1");
|
||||
} else {
|
||||
$posts = BoincPost::enum("thread=$thread->id $clause2 order by timestamp desc limit 1");
|
||||
}
|
||||
$post = $posts[0];
|
||||
$post_date = gmdate('D, d M Y H:i:s',$post->timestamp).' GMT';
|
||||
$t = bb2html($post->content, true);
|
||||
if ($truncate) {
|
||||
if (strlen($post->content) > 256) {
|
||||
$t = substr($post->content, 0, 256).". . .";
|
||||
}
|
||||
}
|
||||
$t = htmlspecialchars($t);
|
||||
echo "<item>
|
||||
<title>".strip_tags(bb2html($thread->title))."</title>
|
||||
<link>$unique_url</link>
|
||||
<guid isPermaLink=\"true\">$unique_url</guid>
|
||||
<description>$t</description>
|
||||
<pubDate>$post_date</pubDate>
|
||||
</item>
|
||||
";
|
||||
}
|
||||
|
||||
function forum_rss($forumid, $userid, $truncate, $threads_only, $ndays) {
|
||||
$clause = "forum=$forumid ";
|
||||
|
||||
|
@ -82,32 +111,7 @@ function forum_rss($forumid, $userid, $truncate, $threads_only, $ndays) {
|
|||
// write news items
|
||||
//
|
||||
foreach ($threads as $thread) {
|
||||
$unique_url=URL_BASE."forum_thread.php?id=".$thread->id;
|
||||
|
||||
$clause2 = " and hidden=0 ";
|
||||
if ($userid) $clause2 .= "and user=$userid";
|
||||
if ($threads_only) {
|
||||
$posts = BoincPost::enum("thread=$thread->id $clause2 order by id limit 1");
|
||||
} else {
|
||||
$posts = BoincPost::enum("thread=$thread->id $clause2 order by timestamp desc limit 1");
|
||||
}
|
||||
$post = $posts[0];
|
||||
$post_date=gmdate('D, d M Y H:i:s',$post->timestamp).' GMT';
|
||||
$t = bb2html($post->content, true);
|
||||
if ($truncate) {
|
||||
if (strlen($post->content) > 256) {
|
||||
$t = substr($post->content, 0, 256).". . .";
|
||||
}
|
||||
}
|
||||
$t = htmlspecialchars($t);
|
||||
echo "<item>
|
||||
<title>".strip_tags(bb2html($thread->title))."</title>
|
||||
<link>$unique_url</link>
|
||||
<guid isPermaLink=\"true\">$unique_url</guid>
|
||||
<description>$t</description>
|
||||
<pubDate>$post_date</pubDate>
|
||||
</item>
|
||||
";
|
||||
show_forum_rss_item($thread, $truncate);
|
||||
}
|
||||
|
||||
echo "
|
||||
|
|
|
@ -26,4 +26,30 @@ function notify_rss_url($user) {
|
|||
return URL_BASE."notify_rss.php?userid=$user->id&auth=".notify_rss_auth($user);
|
||||
}
|
||||
|
||||
function show_notify_rss_item($notify) {
|
||||
switch ($notify->type) {
|
||||
case NOTIFY_FRIEND_REQ:
|
||||
friend_req_rss($notify, $title, $msg, $url);
|
||||
break;
|
||||
case NOTIFY_FRIEND_ACCEPT:
|
||||
friend_accept_rss($notify, $title, $msg, $url);
|
||||
break;
|
||||
case NOTIFY_PM:
|
||||
pm_rss($notify, $title, $msg, $url);
|
||||
break;
|
||||
case NOTIFY_SUBSCRIBED_POST:
|
||||
subscribe_rss($notify, $title, $msg, $url);
|
||||
break;
|
||||
}
|
||||
|
||||
$news_date=gmdate('D, d M Y H:i:s',$notify->create_time) . ' GMT';
|
||||
echo "<item>
|
||||
<title>$title</title>
|
||||
<link>".htmlentities($url)."</link>
|
||||
<description><![CDATA[$msg]]></description>
|
||||
<pubDate>$news_date</pubDate>
|
||||
</item>
|
||||
";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -196,8 +196,8 @@ function pm_email_remind($user) {
|
|||
function pm_rss($notify, &$title, &$msg, &$url) {
|
||||
$pm = BoincPrivateMessage::lookup_id($notify->opaque);
|
||||
$from_user = BoincUser::lookup_id($pm->senderid);
|
||||
$title = "New private message";
|
||||
$msg = "$from_user->name sent you a private message; subject: $pm->subject";
|
||||
$title = "Private message from $from_user->name: $pm->subject";
|
||||
$msg = "$pm->content";
|
||||
$url = URL_BASE."pm.php";
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2010 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/news.inc");
|
||||
require_once("../inc/notify.inc");
|
||||
require_once("../inc/forum_rss.inc");
|
||||
|
||||
function notice_cmp($a, $b) {
|
||||
return $a->time < $b->time;
|
||||
}
|
||||
|
||||
function notices_rss_start() {
|
||||
$t = gmdate('D, d M Y H:i:s', time())." GMT";
|
||||
header("Expires: $t");
|
||||
header("Last-Modified: $t");
|
||||
header("Content-Type: application/xml");
|
||||
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>
|
||||
<rss version=\"2.0\">
|
||||
<channel>
|
||||
<title>".PROJECT." notices</title>
|
||||
<link>".URL_BASE."</link>
|
||||
<description>Notices</description>
|
||||
<lastBuildDate>$t</lastBuildDate>
|
||||
";
|
||||
}
|
||||
|
||||
function notices_rss_end() {
|
||||
echo "
|
||||
</channel>
|
||||
</rss>
|
||||
";
|
||||
}
|
||||
|
||||
$userid = get_int('userid');
|
||||
$auth = get_str('auth');
|
||||
$seqno = get_int('auth', true);
|
||||
|
||||
$user = BoincUser::lookup_id($userid);
|
||||
if (!$user) xml_error();
|
||||
//if (notify_rss_auth($user) != $auth) xml_error();
|
||||
|
||||
$seqno_clause = $seqno?"and create_time > $seqno":"";
|
||||
|
||||
$notifies = BoincNotify::enum("userid = $userid $seqno_clause");
|
||||
|
||||
$forum = news_forum();
|
||||
if ($forum) {
|
||||
$threads = BoincThread::enum(
|
||||
"forum = $forum->id and hidden=0 $seqno_clause"
|
||||
);
|
||||
}
|
||||
|
||||
// there may be a better way to do this
|
||||
|
||||
$items = array();
|
||||
foreach ($notifies as $n) {
|
||||
$i = null;
|
||||
$i->type = 0;
|
||||
$i->time = $n->create_time;
|
||||
$i->val = $n;
|
||||
$items[] = $i;
|
||||
}
|
||||
|
||||
foreach ($threads as $t) {
|
||||
$i = null;
|
||||
$i->type = 1;
|
||||
$i->time = $t->create_time;
|
||||
$i->val = $t;
|
||||
$items[] = $i;
|
||||
}
|
||||
|
||||
usort($items, 'notice_cmp');
|
||||
|
||||
notices_rss_start();
|
||||
foreach ($items as $item) {
|
||||
switch ($item->type) {
|
||||
case 0:
|
||||
show_notify_rss_item($item->val);
|
||||
break;
|
||||
case 1:
|
||||
show_forum_rss_item($item->val, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
notices_rss_end();
|
||||
|
||||
?>
|
|
@ -66,30 +66,7 @@ echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>
|
|||
";
|
||||
|
||||
foreach ($notifies as $notify) {
|
||||
switch ($notify->type) {
|
||||
case NOTIFY_FRIEND_REQ:
|
||||
friend_req_rss($notify, $title, $msg, $url);
|
||||
break;
|
||||
case NOTIFY_FRIEND_ACCEPT:
|
||||
friend_accept_rss($notify, $title, $msg, $url);
|
||||
break;
|
||||
case NOTIFY_PM:
|
||||
pm_rss($notify, $title, $msg, $url);
|
||||
break;
|
||||
case NOTIFY_SUBSCRIBED_POST:
|
||||
subscribe_rss($notify, $title, $msg, $url);
|
||||
break;
|
||||
}
|
||||
|
||||
$news_date=gmdate('D, d M Y H:i:s',$notify->create_time) . ' GMT';
|
||||
$unique_url=URL_BASE."home.php";
|
||||
echo "<item>
|
||||
<title>$title</title>
|
||||
<link>".htmlentities($url)."</link>
|
||||
<description><![CDATA[$msg]]></description>
|
||||
<pubDate>$news_date</pubDate>
|
||||
</item>
|
||||
";
|
||||
show_notify_rss_item($notify);
|
||||
}
|
||||
|
||||
echo "
|
||||
|
|
|
@ -96,12 +96,6 @@ static bool find_host_by_other(DB_USER& user, HOST req_host, DB_HOST& host) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
static void get_weak_auth(USER& user, char* buf) {
|
||||
char buf2[256], out[256];
|
||||
sprintf(buf2, "%s%s", user.authenticator, user.passwd_hash);
|
||||
md5_block((unsigned char*)buf2, strlen(buf2), out);
|
||||
sprintf(buf, "%d_%s", user.id, out);
|
||||
}
|
||||
|
||||
static void send_error_message(const char* msg, int delay) {
|
||||
g_reply->insert_message(msg, "low");
|
||||
|
|
|
@ -1194,7 +1194,7 @@ void GUI_URLS::init() {
|
|||
|
||||
void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf) {
|
||||
bool found;
|
||||
char userid[256], teamid[256], hostid[256];
|
||||
char userid[256], teamid[256], hostid[256], weak_auth[256], rss_auth[256];
|
||||
strcpy(buf, "");
|
||||
if (!text) return;
|
||||
strcpy(buf, text);
|
||||
|
@ -1208,8 +1208,10 @@ void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf) {
|
|||
while (remove_element(buf, "<ifteam>", "</ifteam>")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
get_weak_auth(user, weak_auth);
|
||||
get_rss_auth(user, rss_auth);
|
||||
while (1) {
|
||||
found = false;
|
||||
found |= str_replace(buf, "<userid/>", userid);
|
||||
|
@ -1218,6 +1220,8 @@ void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf) {
|
|||
found |= str_replace(buf, "<teamid/>", teamid);
|
||||
found |= str_replace(buf, "<team_name/>", team.name);
|
||||
found |= str_replace(buf, "<authenticator/>", user.authenticator);
|
||||
found |= str_replace(buf, "<weak_auth/>", weak_auth);
|
||||
found |= str_replace(buf, "<rss_auth/>", rss_auth);
|
||||
if (!found) break;
|
||||
}
|
||||
}
|
||||
|
@ -1227,4 +1231,18 @@ void PROJECT_FILES::init() {
|
|||
read_file_malloc(config.project_path("project_files.xml"), text);
|
||||
}
|
||||
|
||||
void get_weak_auth(USER& user, char* buf) {
|
||||
char buf2[256], out[256];
|
||||
sprintf(buf2, "%s%s", user.authenticator, user.passwd_hash);
|
||||
md5_block((unsigned char*)buf2, strlen(buf2), out);
|
||||
sprintf(buf, "%d_%s", user.id, out);
|
||||
}
|
||||
|
||||
void get_rss_auth(USER& user, char* buf) {
|
||||
char buf2[256], out[256];
|
||||
sprintf(buf2, "%s%s%s", user.authenticator, user.passwd_hash, "notify_rss");
|
||||
md5_block((unsigned char*)buf2, strlen(buf2), out);
|
||||
sprintf(buf, "%d_%s", user.id, out);
|
||||
}
|
||||
|
||||
const char *BOINC_RCSID_ea659117b3 = "$Id$";
|
||||
|
|
|
@ -469,4 +469,7 @@ static inline void add_no_work_message(char* m) {
|
|||
g_wreq->add_no_work_message(m);
|
||||
}
|
||||
|
||||
extern void get_weak_auth(USER&, char*);
|
||||
extern void get_rss_auth(USER&, char*);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue