Commit Graph

102 Commits

Author SHA1 Message Date
David Anderson a3b2be239f Compile fixes for C++11, from Rene Ladan 2013-11-05 09:19:27 -08:00
Rom Walton 3aaeadaf99 API: On Windows, when BOINC runs under 'boinc_master' and a project application runs under 'boinc_project' the new heartbeat mechanism was failing. OpenProcess would return a NULL handle and set GetLastError() to ERROR_ACCESS_DENIED. Account for that situation instead of claiming the client isn't running and shutting down the project application. 2013-11-05 11:24:24 -05:00
David Anderson e0dd68194e API (Android): workaround for Android bug in per-thread signal masking
Per-thread signal masking doesn't work in Android pre-4.1.
As a result, the SIGALRM signals used by the BOINC runtime system,
which are supposed to be handled by the worker thread,
sometimes are handled by the timer thread.
As a result, suspended apps never resume.
Workaround: in the SIGALRM handler, see if we're the timer thread.
If so, use pthread_kill() to send a SIGALRM to the work thread, and return.
2013-09-10 11:29:34 -07:00
David Anderson 174c90218c API (Android): fix typo 2013-08-07 09:11:45 -07:00
David Anderson 920df081e4 API (Android): check whether the SIGALRM signal is erroneously being handled by the timer thread 2013-08-02 13:43:58 -07:00
David Anderson 9eb232ab08 API (Android) sched_yield() before sleep() in signal handler
Trying to fix bug where timer thread stops doing anything
after first suspend on Android (old, 1-core devices).
I suspect that the sleep() in the worker thread's signal handle
is sleeping the entire process.
Insert a sched_yield() before the sleep so that the time thread will run.
2013-07-30 11:04:09 -07:00
David Anderson e85a18289e client (win): fix typo in last commit 2013-07-30 10:47:54 -07:00
David Anderson b290ad2e5f API: add debug-mode log messages for mutex acquire/release, to help diagnose Android bug 2013-07-25 14:14:16 -07:00
David Anderson dfcf23bea8 API: Win bug fix: need to create mutex initially free 2013-07-09 17:43:19 -07:00
David Anderson 67c20e9fce API: remove logic that makes new app graphics work with version 5 clients. 2013-07-09 16:22:10 -07:00
David Anderson 213d3a65dc API: fix last commit; need a DesiredAccess arg to OpenProcess() 2013-07-09 14:44:13 -07:00
David Anderson 85c845dde6 API: use OpenProcess(), not EnumProcesses(), to see if client is still alive 2013-07-09 14:27:36 -07:00
David Anderson 519a0bcbef API: add test harness for the runtime system
- If you run the client with --run_test_app,
  runs "test_app" in the current directory and interacts with it
  (and does nothing else).
  It can suspend/resume it with arbitrary timing;
  this is controlled in run_test_app() (app_start.cpp).
- example app: add --critical_section option.
  This lets you test the runtime system for apps that do
  most of their work in a critical section (like GPU apps).
- Add some logging messages (conditioned by DEBUG_BOINC_API)
  to the runtime system.
- boinc_finish() waits for the timer thread to write final messages;
  make sure it doesn't do anything else
  (like suspend the worker thread) during this period
2013-07-04 16:00:10 -07:00
David Anderson ed03f500b2 API: fix synchronization problem that could make apps nonresponsive 2013-07-03 18:08:09 -07:00
David Anderson 78f7610f6e remove dependency of boinc_api.h on str_replace.h (and hence config.h)
Any files that use strlcpy() or strlcat() must directly include str_replace.h
2013-06-06 17:31:46 -07:00
David Anderson 254d8318e8 Merge branch 'master' of ssh://boinc.berkeley.edu/boinc-v2 2013-06-05 15:42:37 -07:00
David Anderson dc43f0b375 API: tweaks to last commit 2013-06-05 15:42:17 -07:00
David Anderson b98bc309cc API: fix bug involving suspend and critical sections
Old: if the timer thread gets a <suspend> message while we're in
a critical section, it sets a "suspend_request" flag.
The timer then periodically (10X/sec) checks whether
suspend_request is set and we're no longer in a critical section;
if so it suspends the worker thread.

Problem (pointed out by Oliver): this doesn't work if the worker thread
is almost always in a critical section
(as is the case for GPU apps, which treat GPU kernels as critical sections).
The app never gets suspended.

New:
1) boinc_end_critical_section() checks suspend_request;
    if set, it calls suspend_activities()
2) On Unix, if suspend_activities() is called from the worker thread,
    it calls sleep() in a loop until the suspension is over.
    (Note: pthreads has no suspend/resume).
3) Add a mutex to protect the data structures shared between
    the timer and worker threads.

Oliver pointed out that
2013-06-05 15:22:39 -07:00
Rom Walton 8a542f13a8 API: Change some strcat's to strlcats 2013-06-05 12:11:20 -04:00
David Anderson 846b8c7757 all components: change strcpy() to strlcpy() when possible.
This commit should cover the client and manager code.
2013-06-03 20:24:48 -07:00
David Anderson 21248a00f8 API: replace strcpy() with strlcpy() various places 2013-06-03 15:04:20 -07:00
David Anderson 553abb040f API: tweaks 2013-05-21 10:26:15 -07:00
Rom Walton 4b3f9b4cb7 Fix build break for boinc_opencl.cpp and move the include of <vector> below the pre-compiled header file for Windows builds in boinc_api.cpp 2013-03-04 17:45:14 +01:00
Rom Walton 076858a729 LIB: Standardize on using windows_format_error_string and drop windows_error_string.
* Move the windows_format_error_string function to win_util.cpp, .h instead of it being scattered between util.h and str_util.cpp.
* Convert the Windows error string into UTF8 before allowing it to be used by the caller
* Remove windows_error_string from library
2013-03-04 17:39:24 +01:00
David Anderson e393203ff7 - API: improve log messages when detect dead client 2013-03-04 17:24:19 +01:00
David Anderson be553882bd - API: fix Unix bug when checking if client is alive based on PID.
Can't use waitpid() here; works only for children.
    Use kill(pid, 0) instead.
2013-03-04 17:24:19 +01:00
David Anderson 17a4ab8db9 David 11 Dec 2012
- Win process control (affects API and wrapper):
		Since Win doesn't have an API for process suspend/resume,
		we were suspending processes by
			1) enumerating all the threads in the system (typically several thousand)
			2) suspending those belonging to the given process
		The problem: for each thread, the code was calling a function
		in diagnostics_win.cpp to see if the thread was exempted from suspension.
		This check (which is unnecessary anyway if we're suspending another process)
		was surrounded by a semaphore acquire/release.
		The result: performance problems.
		It could take a minute to suspend the threads.
		Solution:
			1) do the check for exemption only if we're suspending threads
				in our own process (i.e. from the API)
			2) if we're suspending multiple processes, enumerate the threads
				only once, and see if each one belongs to any of the processes
			3) have the wrapper elevate itself to normal priority.
				Otherwise it can get preempted for long periods,
				sometimes in the middle of scanning the threads.
		Note: post-9x versions of Win have a process group API that includes suspend/resume.
		We'll switch to this soon.
2013-03-04 17:02:40 +01:00
David Anderson 76282d0a20 - Win compile fixes.
For now, include psapi.lib in various project properties.
		Try to figure out a different way.

svn path=/trunk/boinc/; revision=26149
2012-10-11 19:22:34 +00:00
David Anderson 7d40c46923 - client and API: improve the way an app checks for the death of the client
Old: heartbeat mechanism
    Problem: if the client is blocked for > 30 secs
        (e.g. because it takes a long time to write the state file,
        of because it's stopped in a debugger)
        then apps exit.
        This is bad is the app doesn't checkpoint and has been
        running for a long time.
    New: the client passes its PID to the app.
        The app periodically (10 sec) checks that the process still exists.
    Notes:
    - For backward compatibility (e.g. new API w/ old client,
        or vice versa) the client still sends heartbeats,
        and the API checks heartbeats if the client doesn't pass a PID.
    - The new mechanism works only if the client's PID isn't assigned
        to a new process within 10 secs of the client exiting.
        Windows 2000 reuses PIDs immediately, so check for Win2K
        and don't use this mechanism if so.

TODO: For Unix multithread apps,
    critical sections aren't currently being enforced.
    Need to fix this by masking signals.


svn path=/trunk/boinc/; revision=26147
2012-10-11 16:41:31 +00:00
David Anderson be540c8318 - API: if get a resume message from client while in a critical section,
clear the suspend_request flag.
    Otherwise we'll end up doing two suspends,
    and on Win the app will be suspended forever.


svn path=/trunk/boinc/; revision=26143
2012-09-30 20:30:58 +00:00
David Anderson 25c2f6b49c - client: treat all 4xx HTTP errors as permanent
- code cleanup
- API: increase a buffer in timer_handler() from 256 to 512.


svn path=/trunk/boinc/; revision=26012
2012-08-13 18:23:20 +00:00
David Anderson cd1f79fbbc - API: add boinc_set_min_checkpoint_period(int).
Lets application specify a min checkpoint interval.
    The actual min checkpoint interval is the max of this
    and the user-specified pref for min disk interval.


svn path=/trunk/boinc/; revision=26005
2012-08-10 22:20:41 +00:00
David Anderson 9f6fa7c1ad - API, Linux: increase timer thread stack size from 16K to 32K.
Apparently new use of MAXPATHLEN can cause overflow.
    Fixes #1191


svn path=/trunk/boinc/; revision=25781
2012-06-21 19:13:49 +00:00
David Anderson 13f51d42e5 - API: add boinc_network_usage();
lets an application report its network usage to BOINC,
    and hence take it into account with monthly limits etc.
- API: get rid of deprecated boinc_ops_per_cpu_sec(),
    boinc_ops_cumulative(), and
    boinc_set_credit_claim();
- admin web: update manage_apps.php;
    add the ability to set homogeneous app version


svn path=/trunk/boinc/; revision=25700
2012-05-20 23:02:12 +00:00
David Anderson 24c0fcc9bf - another MAXPATHLEN
svn path=/trunk/boinc/; revision=25660
2012-05-09 18:16:15 +00:00
David Anderson 32a08d27d9 - C++ code: use MAXPATHLEN for char arrays that hold paths
svn path=/trunk/boinc/; revision=25659
2012-05-09 16:11:50 +00:00
David Anderson dfacf7d1c1 - API: remove BOINC_STATUS::suspend_request;
it's an implementation thing, not intended for export.
    Fix a related bug.


svn path=/trunk/boinc/; revision=25396
2012-03-09 19:46:49 +00:00
David Anderson fe2f589ae2 - API: fix various bugs related to process control and critical sections.
- client: code cleanup (no functional change)



svn path=/trunk/boinc/; revision=25393
2012-03-08 22:42:44 +00:00
David Anderson 7c3bc68a05 - API, client, and Manager: add an optional "reason" argument to
boinc_temporary_exit(),
        explaining why the app is exiting.
        Convey this to the client, and then to the Manager,
        and display it there and in the log.

    clientgui/
        MainDocument.cpp
    lib/
        gui_rpc_client_ops.cpp
        gui_rpc_client.h
    api/
        boinc_api.cpp,h
    client/
        client_types.cpp,h
        app.h
        app_control.cpp

svn path=/trunk/boinc/; revision=25315
2012-02-22 22:56:05 +00:00
David Anderson 81b29b0cc9 - API: fix queueing problem for graphics-related messages
(web graphics URL and remote desktop addr)
- GUI RPC and API:
    change "remote_desktop_connection" to "remote_desktop_addr" everywhere.
    It's an address, not a connection.
- vboxwrapper: log message cleanup


svn path=/trunk/boinc/; revision=25044
2012-01-13 19:00:16 +00:00
Rom Walton ce4650ecbb - VBOX: Cleanup a few messages stating port numbers in the stderr spew.
- VBOX: Send configuration settings in one message instead of piece meal.
    
    api/
        boinc_api.cpp, .h
    samples/vboxwrapper
        vboxwrapper.cpp

svn path=/trunk/boinc/; revision=25041
2012-01-13 15:21:00 +00:00
Rom Walton 2c54c9735a - VBOX: Report the remote desktop connection information to the
core client.  Next commit will create an extra "VM Console"
        button in the manager when detected.  Volunteers will just have
        to click the button to see what is going on with the VM.

    api/
        boinc_api.cpp, .h
    samples/vboxwrapper
        vbox.cpp, .h
        vboxwrapper.cpp, .h

svn path=/trunk/boinc/; revision=25035
2012-01-12 20:57:23 +00:00
David Anderson 8d1af7892f - API: respect direct_process_action even if multi_process is set
svn path=/trunk/boinc/; revision=25031
2012-01-12 00:27:21 +00:00
David Anderson 17e2cedefe - API/client/manager:
allow applications to supply a "web graphics URL",
    in which case the manager's "Show Graphics" button
    opens a browser at that URL.
    This typically would used for applications that
    implement a web server that serves pages showing
    job information in HTML.
- vboxwrapper: if <pf_guest_port> is specified in the config file,
    set up port forwarding to that port
    and use the above API call with URL "http://localhost:port"


svn path=/trunk/boinc/; revision=24898
2011-12-26 03:10:42 +00:00
David Anderson 1f2accb000 - API: don't crash if send trickle msg running standalone.
From Christian Ries.


svn path=/trunk/boinc/; revision=24357
2011-10-08 16:33:31 +00:00
David Anderson d8f20bceea - vboxwrapper: report network usage to the client
- client: include the above in enforcing network quota preferences


svn path=/trunk/boinc/; revision=24227
2011-09-16 19:16:12 +00:00
David Anderson ec33994fe7 - API; fix the above fix
svn path=/trunk/boinc/; revision=24160
2011-09-12 03:48:16 +00:00
David Anderson 228f626a01 - API: change boinc_get_opencl_ids() to use APP_INIT_DATA
instead of cmdline


svn path=/trunk/boinc/; revision=24159
2011-09-11 22:22:55 +00:00
David Anderson 4e946854c1 - client/API/vboxwrapper:
add a mechanism so that apps can report sub-processes
    that are not descendants (e.g., virtual machines)
    These processes are then counted as part of the app,
    not as "non-BOINC CPU time".
    This fixes a bug where processing was incorrectly suspended
    because CPU usage by VM apps exceeded the "CPU usage limit" pref.

    Implementation:
    - the PIDs of the processes in question
        are passed from app to client via shared-memory,
        in the app_status channel.
        A new variant of boinc_report_app_status() supports this.
    - the VBox wrapper queries the PID of the VM,
        and reports it in this way.
    - procinfo_app() includes a new argument: a list of PIDs
        that are part of the app, although not ancestrally
        related to the main process.
    - in the client, ACTIVE_TASK now includes a vector "other_pids".
        If this is nonempty, it's passed to procinfo_app().


svn path=/trunk/boinc/; revision=24123
2011-09-02 20:47:05 +00:00
David Anderson 8ad9d7d98b - more code shuffling:
proc_control: controlling processes
    procinfo: enumerating and querying processes
    run_app_windows: launching apps as other users on Win


svn path=/trunk/boinc/; revision=24120
2011-09-02 18:23:13 +00:00