[Pkg-owncloud-commits] [owncloud-client] 14/70: Have only one place where we read the timeout

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat May 17 20:01:25 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 988c162d2f74476315bf84117a831da5eb4bb310
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri May 2 13:04:53 2014 +0200

    Have only one place where we read the timeout
---
 csync/src/csync.c                 |  3 ---
 csync/src/csync_owncloud.c        |  7 +++----
 src/mirall/owncloudpropagator.cpp | 12 ++++++++++++
 src/mirall/owncloudpropagator.h   |  3 +++
 src/mirall/propagator_qnam.cpp    | 16 ++--------------
 src/mirall/syncengine.cpp         |  3 +++
 6 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/csync/src/csync.c b/csync/src/csync.c
index 238334c..9a3ba6c 100644
--- a/csync/src/csync.c
+++ b/csync/src/csync.c
@@ -197,9 +197,6 @@ int csync_init(CSYNC *ctx) {
     ctx->remote.type = LOCAL_REPLICA;
   }
 
-  if (ctx->options.timeout)
-    csync_vio_set_property(ctx, "timeout", &ctx->options.timeout);
-
   if (c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp) < 0) {
     ctx->status_code = CSYNC_STATUS_TREE_ERROR;
     rc = -1;
diff --git a/csync/src/csync_owncloud.c b/csync/src/csync_owncloud.c
index 41dc2c5..433271d 100644
--- a/csync/src/csync_owncloud.c
+++ b/csync/src/csync_owncloud.c
@@ -508,10 +508,9 @@ static int dav_connect(const char *base_url) {
         goto out;
     }
 
-    if (dav_session.read_timeout == 0)
-        dav_session.read_timeout = 300;  // set 300 seconds as default.
-
-    ne_set_read_timeout(dav_session.ctx, dav_session.read_timeout);
+    if (dav_session.read_timeout != 0) {
+        ne_set_read_timeout(dav_session.ctx, dav_session.read_timeout);
+    }
 
     snprintf( uaBuf, sizeof(uaBuf), "Mozilla/5.0 (%s) csyncoC/%s",
               get_platform(), CSYNC_STRINGIFY( LIBCSYNC_VERSION ));
diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp
index 9f29644..45f57af 100644
--- a/src/mirall/owncloudpropagator.cpp
+++ b/src/mirall/owncloudpropagator.cpp
@@ -337,5 +337,17 @@ void PropagateDirectory::slotSubJobReady()
     }
 }
 
+int OwncloudPropagator::httpTimeout()
+{
+    static int timeout;
+    if (!timeout) {
+        timeout = qgetenv("OWNCLOUD_TIMEOUT").toUInt();
+        if (timeout == 0) {
+            timeout = 30; // default to 30 secs
+        }
+    }
+    return timeout;
+}
+
 
 }
diff --git a/src/mirall/owncloudpropagator.h b/src/mirall/owncloudpropagator.h
index 69a24f7..47e0959 100644
--- a/src/mirall/owncloudpropagator.h
+++ b/src/mirall/owncloudpropagator.h
@@ -221,6 +221,9 @@ public:
         emit finished();
     }
 
+    // timeout in seconds
+    static int httpTimeout();
+
 
 signals:
     void completed(const SyncFileItem &);
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 5cfadf8..2992061 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -37,18 +37,6 @@ static uint chunkSize() {
     return chunkSize;
 }
 
-static qint64 httpTimeout() {
-    static uint timeout;
-    if (!timeout) {
-        timeout = qgetenv("OWNCLOUD_TIMEOUT").toUInt();
-        if (timeout == 0) {
-            timeout = 30; // default to 30 secs
-        }
-    }
-    return timeout;
-}
-
-
 /**
  * Fiven an error from the network, map to a SyncFileItem::Status error
  */
@@ -233,7 +221,7 @@ void PropagateUploadFileQNAM::startNextChunk()
         device->open(QIODevice::ReadOnly);
 
     _job = new PUTFileJob(AccountManager::instance()->account(), _propagator->_remoteFolder + path, device, headers);
-    _job->setTimeout(httpTimeout() * 1000);
+    _job->setTimeout(_propagator->httpTimeout() * 1000);
     connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotPutFinished()));
     connect(_job, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(slotUploadProgress(qint64,qint64)));
     _job->start();
@@ -513,7 +501,7 @@ void PropagateDownloadFileQNAM::start()
     _job = new GETFileJob(AccountManager::instance()->account(),
                           _propagator->_remoteFolder + _item._file,
                           &_tmpFile, headers, expectedEtagForResume);
-    _job->setTimeout(httpTimeout() * 1000);
+    _job->setTimeout(_propagator->httpTimeout() * 1000);
     connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotGetFinished()));
     connect(_job, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(slotDownloadProgress(qint64,qint64)));
     _propagator->_activeJobs ++;
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index 977bc80..1549dc0 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -499,6 +499,9 @@ void SyncEngine::startSync()
     // csync_set_auth_callback( _csync_ctx, getauth );
     csync_set_log_callback( csyncLogCatcher );
     //csync_set_log_level( 11 ); don't set the loglevel here, it shall be done by folder.cpp or owncloudcmd.cpp
+    int timeout = OwncloudPropagator::httpTimeout();
+    csync_set_module_property(_csync_ctx, "timeout", &timeout);
+
 
     _stopWatch.start();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list