aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-05-20 18:30:02 -0700
committerfriendica <info@friendica.com>2012-05-20 18:30:02 -0700
commitafaf9ec74fe0662de76deabd11d630f871802579 (patch)
tree58e41106d72d5b76e00de9cf82a00ef82b6edd77 /include
parentf16a1199408d167bbc7c52dc408ef02b36808317 (diff)
downloadvolse-hubzilla-afaf9ec74fe0662de76deabd11d630f871802579.tar.gz
volse-hubzilla-afaf9ec74fe0662de76deabd11d630f871802579.tar.bz2
volse-hubzilla-afaf9ec74fe0662de76deabd11d630f871802579.zip
rev update
Diffstat (limited to 'include')
-rw-r--r--include/crypto.php36
-rw-r--r--include/delivery.php2
-rw-r--r--include/notifier.php32
3 files changed, 61 insertions, 9 deletions
diff --git a/include/crypto.php b/include/crypto.php
index 0feb45c24..6fc9a287e 100644
--- a/include/crypto.php
+++ b/include/crypto.php
@@ -292,4 +292,38 @@ function zot_unencapsulate($data,$prvkey) {
$ret['sender'] = $s;
$ret['data'] = aes_unencapsulate($x,$prvkey);
return $ret;
-} \ No newline at end of file
+}
+
+function new_keypair($bits) {
+
+ $openssl_options = array(
+ 'digest_alg' => 'sha1',
+ 'private_key_bits' => $bits,
+ 'encrypt_key' => false
+ );
+
+ $conf = get_config('system','openssl_conf_file');
+ if($conf)
+ $openssl_options['config'] = $conf;
+
+ $result = openssl_pkey_new($openssl_options);
+
+ if(empty($result)) {
+ logger('new_keypair: failed');
+ return false;
+ }
+
+ // Get private key
+
+ $response = array('prvkey' => '', 'pubkey' => '');
+
+ openssl_pkey_export($result, $response['prvkey']);
+
+ // Get public key
+ $pkey = openssl_pkey_get_details($result);
+ $response['pubkey'] = $pkey["key"];
+
+ return $response;
+
+}
+
diff --git a/include/delivery.php b/include/delivery.php
index 1cee2d697..61b0bd33a 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -41,7 +41,7 @@ function delivery_run($argv, $argc){
for($x = 3; $x < $argc; $x ++) {
- $contact_id = intval($argv[x]);
+ $contact_id = intval($argv[$x]);
// Some other process may have delivered this item already.
diff --git a/include/notifier.php b/include/notifier.php
index 8b904dbcd..cb4fb2a31 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -478,24 +478,42 @@ function notifier_run($argv, $argc){
}
}
+
+ // This controls the number of deliveries to execute with each separate delivery process.
+ // By default we'll perform one delivery per process. Assuming a hostile shared hosting
+ // provider, this provides the greatest chance of deliveries if processes start getting
+ // killed. We can also space them out with the delivery_interval to also help avoid them
+ // getting whacked.
+
+ // If $deliveries_per_process > 1, we will chain this number of multiple deliveries
+ // together into a single process. This will reduce the overall number of processes
+ // spawned for each delivery, but they will run longer.
+
$deliveries_per_process = intval(get_config('system','delivery_batch_count'));
if($deliveries_per_process <= 0)
$deliveries_per_process = 1;
$this_batch = array();
- foreach($r as $contact) {
+ for($x = 0; $x < count($r); $x ++) {
+ $contact = $r[$x];
+
if($contact['self'])
continue;
// potentially more than one recipient. Start a new process and space them out a bit.
- // we will deliver single recipient types of message and email receipients here.
-
+ // we will deliver single recipient types of message and email recipients here.
+
if((! $mail) && (! $fsuggest) && (! $followup)) {
- // deliveries per process not yet implemented, 1 delivery per process.
- proc_run('php','include/delivery.php',$cmd,$item_id,$contact['id']);
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+
+ $this_batch[] = $contact['id'];
+
+ if(count($this_batch) == $deliveries_per_process) {
+ proc_run('php','include/delivery.php',$cmd,$item_id,$this_batch);
+ $this_batch = array();
+ if($interval)
+ @time_sleep_until(microtime(true) + (float) $interval);
+ }
continue;
}