forked from rufuscoder/Shakespeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DESIGN
52 lines (43 loc) · 2.32 KB
/
DESIGN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
This is an attempt at describing the overall design choices made when creating
ShakesPeer.
Processes and inter-process communication
-----------------------------------------
The ShakesPeer program is not really one program, but three. Those are sphubd,
sphashd and the UI (user interface). Those three parts are run as separate
processes. Inter-process communication between those three programs is achieved
by using sockets. By default, unix sockets are used, which are local. Using
unix sockets, all programs must be running on the same computer. Replacing the
unix socket with a TCP socket enables the programs to run on different
machines. In fact, sphubd already has that option when communcating with the
UI.
Portability
-----------
The core servers (sphubd and sphashd) are written in C. Actually C99 with GCC
extensions, so GCC is required for compilation. Otherwise they should be quite
portable across Unix-like operating systems. At least Darwin (Mac OS X), Linux
and OpenBSD are supported.
There are currently two user interfaces: one command line client and the
graphical user interface for Mac OS X. The command line client should be
portable, but the OS X GUI requires Mac OS X. Creating different user
interfaces for different platforms and/or GUI toolkits is made easier by having
most of the functionality in the core servers.
sphubd
------
The sphubd process is responsible for hub communication, peer communication
(uploads/downloads), handling the download queue and shared files, listening
for search results and communicating events to the UI.
Persistence of the download queue and file hashes (TTHs) is achieved with
simple text-based database logfiles.
No threads are used. This is a very important design choice, and is what
separates ShakesPeer from most other DC implementations. Preemptive threads
are a PITA.
FIXME: describe event loops ...
sphashd
-------
The sphashd process is responsible for hashing files. The reason this is a
separate process from sphubd is to be able to decrease the priority level
("nice" value). Since hashing is a CPU intensive and quite lengthy task,
reducing the priority of the sphashd process enables the user to actually use
the computer for other tasks. Note that if no other programs use the CPU,
sphashd will still use near 100% CPU, but will "step aside" as soon as another
process is running.