2
2
* This file is part of Soprano Project.
4
4
* Copyright (C) 2010-2012 Sebastian Trueg <trueg@kde.org>
5
* Copyright (C) 2012 Vishesh Handa <me@vhanda.in>
6
7
* This library is free software; you can redistribute it and/or
7
8
* modify it under the terms of the GNU Library General Public
84
85
tv.tv_usec = (timeout % 1000) * 1000;
86
87
int r = ::select( m_handle + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
89
if ( errno == EINTR /* Interrupted system call */ )
90
return waitForReadyRead( timeout );
95
qint64 Soprano::Socket::read( char* buffer, qint64 max )
101
qint64 Soprano::Socket::read( char* buffer, qint64 size )
97
qint64 r = ::read( m_handle, buffer, max );
99
setError( QString::fromLatin1( "Failed to read from fd %1 (%2)" ).arg( m_handle ).arg( QLatin1String( strerror( errno ) ) ) );
105
int bytesRead = ::read( m_handle, buffer, size );
106
if( bytesRead == -1 ) {
107
if (errno == EINTR) {
111
QString error = QString::fromLatin1( "Failed to read from fd %1 (%2)")
113
.arg( QLatin1String( strerror( errno) ) );
118
else if( bytesRead == 0 ) {
119
QString error = QString::fromLatin1( "Timeout after reading %1 of %2 bytes" )
120
.arg( total ).arg( total + size );
105
qint64 Soprano::Socket::write( const char* buffer, qint64 max )
134
qint64 Soprano::Socket::write( const char* buffer, qint64 size )
107
qint64 r = ::write( m_handle, buffer, max );
109
setError( QString::fromLatin1( "Failed to write to fd %1 (%2)" ).arg( m_handle ).arg( QLatin1String( strerror( errno ) ) ) );
138
int written = ::write( m_handle, buffer, size );
140
if (errno == EINTR) {
144
QString error = QString::fromLatin1( "Failed to write fd %1 (%2)")
146
.arg( QLatin1String( strerror( errno) ) );
151
else if( written == 0 ) {
152
QString error = QString::fromLatin1( "Timeout after writing %1 of %2 bytes" )
153
.arg( total ).arg( total + size );