Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

Commit

Permalink
merge back from debug-dev - #27 #26 #25
Browse files Browse the repository at this point in the history
git-svn-id: https://www.dropr.org/svn/trunk@167 f77b8f78-39ad-454d-97bc-04c3ead53514
  • Loading branch information
Soenke Ruempler committed Feb 10, 2008
1 parent e68bc23 commit aec4ef4
Show file tree
Hide file tree
Showing 30 changed files with 194 additions and 246 deletions.
8 changes: 6 additions & 2 deletions client/classes/Client.php → classes/Client.php
Expand Up @@ -19,9 +19,13 @@ public function __construct(dropr_Client_Storage_Abstract $storage)
mkdir($ipcPath, 0777, true);
}
if (!is_file($channelName)) {
posix_mknod($channelName, 0666);
if (!posix_mknod($channelName, 0666)) {
throw new Exception("could not mknod $channelName!");
}
}
$this->ipcChannel = msg_get_queue(ftok($channelName,'*'));

dropr::log("doing ftok($channelName)", LOG_DEBUG);
$this->ipcChannel = msg_get_queue(ftok($channelName, '*'));
}

public function getIpcChannel()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -65,6 +65,8 @@ private function httpFileUpload(array &$messages, $type) {
foreach ($connomains as $i => $url) {
$conn[$i] = curl_init();

// set the timeout to 60 seconds
curl_setopt($conn[$i], CURLOPT_TIMEOUT, 60);
curl_setopt($conn[$i], CURLOPT_URL, $url);
curl_setopt($conn[$i], CURLOPT_POST, true);
curl_setopt($conn[$i], CURLOPT_POSTFIELDS, $uploadFields);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -47,12 +47,13 @@ public function put(dropr_Server_Message $message)
$proc = $this->buildMessagePath($message, self::SPOOLDIR_TYPE_SPOOL);
$done = $this->buildMessagePath($message, self::SPOOLDIR_TYPE_PROCESSED);

/* @var $file SplFileInfo */

if (file_exists ($proc) || file_exists ($done)) {
return;
}
if (!rename($src, $proc)) {

// sometimes php throws a warning but returns true and the file is moved
// .. maybe NFS issue so we have to use the @-operator
if (!@rename($src, $proc)) {
throw new dropr_Server_Exception("Could not save $src to $proc");
}
} else {
Expand Down
Expand Up @@ -16,7 +16,8 @@ public function handle()

// xxx check the check
if (!isset($_POST['metaData']) || !is_string($_POST['metaData']) || (!$metadata = unserialize($_POST['metaData']))) {
throw new Exception("No client metadata set!");
error_log(print_r($_POST['metaData'], true));
throw new Exception("No client metadata set!");
}

#print_r($_FILES);exit;
Expand Down
91 changes: 90 additions & 1 deletion classes/dropr.php
@@ -1,8 +1,97 @@
<?php
/**
* dropr main class
*
* - constants
* - logging
* - autoloading
*
* @author Soenke Ruempler <soenke@ruempler.eu>
*/
class dropr
{
/**
* The message is processed
*/
const MESSAGE_PROCESSED = 1;
}

/**
* Mapping for error-levels
*
* @var array
*/
private static $errorLevels = array(
LOG_ERR,
LOG_CRIT,
LOG_WARNING,
LOG_INFO,
LOG_DEBUG,
);

/**
* the current log-level
*
* @var int
*/
private static $logLevel = LOG_DEBUG;

/**
* set the log level
*
* @param unknown_type $logLevel
*/
public static function setLogLevel($logLevel)
{
self::$logLevel = $logLevel;
}

/**
* logging for the dropr services. can be
* - syslog for daemons
* - error_log for http processes
*
* currently only syslog is implemented
*
* @param string $message
* @param int $level
*/
public static function log($message, $level = LOG_INFO)
{
if ($level <= self::$logLevel) {
syslog($level, $message);
}
}

public static function autoload($className)
{
if (strpos($className, 'dropr_') !== 0) {
return;
}


$file = substr(str_replace('_', '/', $className), 6) . '.php';
require self::$classRoot . $file;
}

private static $classRoot;

public static function setClassRoot($classRoot)
{
self::$classRoot = $classRoot;
}
}

/*
* enable autoloading
*/
spl_autoload_register(array('dropr', 'autoload'));

/*
* set the class root path once
*/
dropr::setClassRoot(realpath(dirname(__FILE__)) . '/');

/*
* set the syslog variables
*/
openlog('dropr', LOG_ODELAY | LOG_PID, LOG_DAEMON);
8 changes: 0 additions & 8 deletions classes/pmq.php

This file was deleted.

106 changes: 0 additions & 106 deletions client/bin/client_queue-fork.php

This file was deleted.

0 comments on commit aec4ef4

Please sign in to comment.