Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Backport [24994] from trunk.

Disable only the ReadyRead callbacks for FileTransfer uploads. Previously,
we disabled all callbacks which caused the upload socket to not be closed
properly when the upload completed.

Closes #8519.

This bumps the binary API version since libmythdb is modified, so make clean,
recompiled plugins, whatever you normally do in this case. 



git-svn-id: http://svn.mythtv.org/svn/branches/release-0-23-fixes@25127 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information...
commit f0b7a14e0dfba59355ca785360cb83c5c7cc4584 1 parent b4a4001
Chris Pinkham cpinkham authored
19 mythtv/libs/libmythdb/mythsocket.cpp
@@ -34,6 +34,7 @@ MythSocketThread *MythSocket::s_readyread_thread = new MythSocketThread();
34 34
35 35 MythSocket::MythSocket(int socket, MythSocketCBs *cb)
36 36 : MSocketDevice(MSocketDevice::Stream), m_cb(cb),
  37 + m_useReadyReadCallback(true),
37 38 m_state(Idle), m_addr(), m_port(0),
38 39 m_ref_count(0), m_notifyread(false)
39 40 {
@@ -200,6 +201,24 @@ void MythSocket::close(void)
200 201 }
201 202 }
202 203
  204 +bool MythSocket::closedByRemote(void)
  205 +{
  206 + fd_set rfds;
  207 + FD_ZERO(&rfds);
  208 + FD_SET(socket(), &rfds);
  209 +
  210 + struct timeval to;
  211 + to.tv_sec = 0;
  212 + to.tv_usec = 1000;
  213 +
  214 + int rval = select(socket() + 1, &rfds, NULL, NULL, &to);
  215 +
  216 + if (rval > 0 && FD_ISSET(socket(), &rfds) && !bytesAvailable())
  217 + return true;
  218 +
  219 + return false;
  220 +}
  221 +
203 222 qint64 MythSocket::readBlock(char *data, quint64 len)
204 223 {
205 224 VERBOSE(VB_SOCKET|VB_EXTRA, LOC + QString("readBlock(0x%1, %2) called")
4 mythtv/libs/libmythdb/mythsocket.h
@@ -29,6 +29,7 @@ class MPUBLIC MythSocket : public MSocketDevice
29 29 };
30 30
31 31 void close(void);
  32 + bool closedByRemote(void);
32 33 void deleteLater(void);
33 34
34 35 void UpRef(void);
@@ -43,6 +44,8 @@ class MPUBLIC MythSocket : public MSocketDevice
43 44
44 45 void setSocket(int socket, Type type = MSocketDevice::Stream);
45 46 void setCallbacks(MythSocketCBs *cb);
  47 + void useReadyReadCallback(bool useReadyReadCallback = true)
  48 + { m_useReadyReadCallback = useReadyReadCallback; }
46 49
47 50 qint64 readBlock(char *data, quint64 len);
48 51 qint64 writeBlock(const char *data, quint64 len);
@@ -73,6 +76,7 @@ class MPUBLIC MythSocket : public MSocketDevice
73 76 void setState(const State state);
74 77
75 78 MythSocketCBs *m_cb;
  79 + bool m_useReadyReadCallback;
76 80 State m_state;
77 81 QHostAddress m_addr;
78 82 quint16 m_port;
4 mythtv/libs/libmythdb/mythsocketthread.cpp
@@ -153,12 +153,12 @@ void MythSocketThread::ReadyToBeRead(MythSocket *sock)
153 153 VERBOSE(VB_SOCKET, SLOC(sock) + "socket is readable");
154 154 int bytesAvail = sock->bytesAvailable();
155 155
156   - if (bytesAvail == 0)
  156 + if (bytesAvail == 0 && sock->closedByRemote())
157 157 {
158 158 VERBOSE(VB_SOCKET, SLOC(sock) + "socket closed");
159 159 sock->close();
160 160 }
161   - else if (sock->m_cb)
  161 + else if (bytesAvail > 0 && sock->m_cb && sock->m_useReadyReadCallback)
162 162 {
163 163 sock->m_notifyread = true;
164 164 VERBOSE(VB_SOCKET, SLOC(sock) + "calling m_cb->readyRead()");
6 mythtv/libs/libmythdb/mythversion.h
@@ -9,9 +9,9 @@
9 9 #endif
10 10
11 11 /// Update this whenever the plug-in API changes.
12   -/// Including changes in the libmythdb, libmyth and libmythui class methods
13   -/// used by plug-ins.
14   -#define MYTH_BINARY_VERSION "0.23.20100429-1"
  12 +/// Including changes in the libmythdb, libmyth, libmythtv, libmythav* and
  13 +/// libmythui class methods used by plug-ins.
  14 +#define MYTH_BINARY_VERSION "0.23.201000617-1"
15 15
16 16 /** \brief Increment this whenever the MythTV network protocol changes.
17 17 *
3  mythtv/programs/mythbackend/filetransfer.cpp
@@ -41,6 +41,9 @@ FileTransfer::FileTransfer(QString &filename, MythSocket *remote, bool write) :
41 41 pginfo->pathname = pginfo->GetPlaybackURL();
42 42 pginfo->MarkAsInUse(true, kFileTransferInUseID);
43 43 }
  44 +
  45 + if (write)
  46 + remote->useReadyReadCallback(false);
44 47 }
45 48
46 49 FileTransfer::~FileTransfer()
11 mythtv/programs/mythbackend/mainserver.cpp
@@ -1270,15 +1270,10 @@ void MainServer::HandleAnnounce(QStringList &slist, QStringList commands,
1270 1270 else
1271 1271 filename = LocalFilePath(qurl, wantgroup);
1272 1272
1273   - if (writemode)
1274   - {
1275   - socket->setCallbacks(NULL);
1276   - ft = new FileTransfer(filename, socket, true);
1277   - }
1278   - else if (retries >= 0)
1279   - ft = new FileTransfer(filename, socket, usereadahead, retries);
  1273 + if (retries < 0)
  1274 + ft = new FileTransfer(filename, socket, writemode);
1280 1275 else
1281   - ft = new FileTransfer(filename, socket, false);
  1276 + ft = new FileTransfer(filename, socket, usereadahead, retries);
1282 1277
1283 1278 sockListLock.lockForWrite();
1284 1279 fileTransferList.push_back(ft);

0 comments on commit f0b7a14

Please sign in to comment.
Something went wrong with that request. Please try again.