[Pkg-owncloud-commits] [owncloud-client] 93/115: SocketAPI: Add parameter to enable wait for the socket write.

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Aug 29 22:04:05 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 d1a660ce2048f153fdcd9fab4ec658903bf50651
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Wed Aug 20 16:24:06 2014 +0200

    SocketAPI: Add parameter to enable wait for the socket write.
    
    This is needed to wait until the UNREGISTER message is sent to the
    shell code when mirall shuts down.
---
 src/mirall/socketapi.cpp | 11 +++++++----
 src/mirall/socketapi.h   |  4 ++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/mirall/socketapi.cpp b/src/mirall/socketapi.cpp
index 18a22b1..2ef9279 100644
--- a/src/mirall/socketapi.cpp
+++ b/src/mirall/socketapi.cpp
@@ -261,7 +261,7 @@ void SocketApi::slotUnregisterPath( const QString& alias )
 {
     Folder *f = FolderMan::instance()->folder(alias);
     if (f) {
-        broadcastMessage(QLatin1String("UNREGISTER_PATH"), f->path() );
+        broadcastMessage(QLatin1String("UNREGISTER_PATH"), f->path(), QString::null, true );
     }
 }
 
@@ -304,7 +304,7 @@ void SocketApi::slotJobCompleted(const QString &folder, const SyncFileItem &item
 
 
 
-void SocketApi::sendMessage(QTcpSocket *socket, const QString& message)
+void SocketApi::sendMessage(QTcpSocket *socket, const QString& message, bool doWait)
 {
     DEBUG << "Sending message: " << message;
     QString localMessage = message;
@@ -312,13 +312,16 @@ void SocketApi::sendMessage(QTcpSocket *socket, const QString& message)
         localMessage.append(QLatin1Char('\n'));
     }
     qint64 sent = socket->write(localMessage.toUtf8());
+    if( doWait ) {
+        socket->waitForBytesWritten(1000);
+    }
     if( sent != localMessage.toUtf8().length() ) {
         qDebug() << "WARN: Could not send all data on socket for " << localMessage;
     }
 
 }
 
-void SocketApi::broadcastMessage( const QString& verb, const QString& path, const QString& status )
+void SocketApi::broadcastMessage( const QString& verb, const QString& path, const QString& status, bool doWait )
 {
     QString msg(verb);
 
@@ -333,7 +336,7 @@ void SocketApi::broadcastMessage( const QString& verb, const QString& path, cons
 
     DEBUG << "Broadcasting to" << _listeners.count() << "listeners: " << msg;
     foreach(QTcpSocket *socket, _listeners) {
-        sendMessage(socket, msg);
+        sendMessage(socket, msg, doWait);
     }
 }
 
diff --git a/src/mirall/socketapi.h b/src/mirall/socketapi.h
index cd8cbdf..e8f4ac0 100644
--- a/src/mirall/socketapi.h
+++ b/src/mirall/socketapi.h
@@ -48,8 +48,8 @@ private slots:
     void slotJobCompleted(const QString &, const SyncFileItem &);
 
 private:
-    void sendMessage(QTcpSocket* socket, const QString& message);
-    void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null);
+    void sendMessage(QTcpSocket* socket, const QString& message, bool doWait = false);
+    void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null, bool doWait = false);
 
     Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, QTcpSocket* socket);
     Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, QTcpSocket* socket);

-- 
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