PIP Bugfixes #207
+1
-1
@@ -6,7 +6,7 @@ endif()
|
||||
project(PIP)
|
||||
set(PIP_MAJOR 5)
|
||||
set(PIP_MINOR 8)
|
||||
set(PIP_REVISION 0)
|
||||
set(PIP_REVISION 1)
|
||||
set(PIP_SUFFIX _beta)
|
||||
set(PIP_COMPANY SHS)
|
||||
set(PIP_DOMAIN org.SHS)
|
||||
|
||||
@@ -880,7 +880,7 @@ bool PITerminal::initialize() {
|
||||
execvp(argv[0], argv);
|
||||
delete[] argv[0];
|
||||
delete[] argv;
|
||||
exit(0);
|
||||
exit(errno);
|
||||
} else {
|
||||
if (fr < 0 || PRIVATE->fd < 0) {
|
||||
piCoutObj << "forkpty error," << errorString();
|
||||
|
||||
@@ -90,11 +90,12 @@ bool PIWaitEvent::wait(int fd, CheckRole role) {
|
||||
FD_SET(fd, &(fds[CheckExeption]));
|
||||
if (fd_index != CheckExeption) FD_SET(fd, &(fds[fd_index]));
|
||||
int sr = ::select(nfds, &(fds[CheckRead]), &(fds[CheckWrite]), &(fds[CheckExeption]), nullptr);
|
||||
if (sr < 0) return false;
|
||||
errorClear();
|
||||
int buf = 0;
|
||||
while (::read(pipe_fd[ReadEnd], &buf, sizeof(buf)) > 0)
|
||||
;
|
||||
while (::read(pipe_fd[ReadEnd], &buf, sizeof(buf)) > 0) {}
|
||||
// piCout << "wait result" << sr << FD_ISSET(fd, &(fds[CheckExeption])) << FD_ISSET(fd, &(fds[fd_index]));
|
||||
if (sr == EBADF || sr == EINTR) return false;
|
||||
if (errno == EBADF || errno == EINTR) return false;
|
||||
if (FD_ISSET(fd, &(fds[CheckExeption]))) return true;
|
||||
return FD_ISSET(fd, &(fds[fd_index]));
|
||||
#endif
|
||||
|
||||
@@ -102,7 +102,11 @@
|
||||
|
||||
#ifndef WINDOWS
|
||||
PIString getSockAddr(sockaddr * s) {
|
||||
return s == 0 ? PIString() : PIStringAscii(inet_ntoa(((sockaddr_in *)s)->sin_addr));
|
||||
if (!s) return PIString();
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
piZeroMemory(buf, sizeof(buf));
|
||||
const char * r = inet_ntop(AF_INET, &((sockaddr_in *)s)->sin_addr, buf, sizeof(buf));
|
||||
return r ? PIStringAscii(r) : PIString();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -861,6 +865,7 @@ ssize_t PIEthernet::writeDevice(const void * data, ssize_t max_size) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
ret += sr;
|
||||
remain_data += sr;
|
||||
remain_size -= sr;
|
||||
}
|
||||
@@ -1176,12 +1181,18 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
# ifdef ANDROID
|
||||
struct ifconf ifc;
|
||||
int s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||
if (s == -1) {
|
||||
piCout << "[PIEthernet]"
|
||||
<< "Can`t create socket: %1"_tr("PIEthernet").arg(errorString());
|
||||
return il;
|
||||
}
|
||||
ifc.ifc_len = 256;
|
||||
ifc.ifc_buf = new char[ifc.ifc_len];
|
||||
if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
|
||||
piCout << "[PIEthernet]"
|
||||
<< "Can`t get interfaces: %1"_tr("PIEthernet").arg(errorString());
|
||||
delete[] ifc.ifc_buf;
|
||||
::close(s);
|
||||
return il;
|
||||
}
|
||||
int icnt = ifc.ifc_len / sizeof(ifreq);
|
||||
@@ -1200,7 +1211,8 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
if (ci.address == "127.0.0.1") ci.flags |= PIEthernet::ifLoopback;
|
||||
il << ci;
|
||||
}
|
||||
delete ifc.ifc_buf;
|
||||
delete[] ifc.ifc_buf;
|
||||
::close(s);
|
||||
# else
|
||||
struct ifaddrs *ret, *cif = 0;
|
||||
int s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||
@@ -1291,8 +1303,10 @@ PINetworkAddress PIEthernet::interfaceAddress(const PIString & interface_) {
|
||||
piZeroMemory(ifr);
|
||||
strcpy(ifr.ifr_name, interface_.dataAscii());
|
||||
int s = ::socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s != -1) {
|
||||
ioctl(s, SIOCGIFADDR, &ifr);
|
||||
::close(s);
|
||||
}
|
||||
struct sockaddr_in * sa = (struct sockaddr_in *)&ifr.ifr_addr;
|
||||
return PINetworkAddress(uint(sa->sin_addr.s_addr));
|
||||
#endif
|
||||
|
||||
@@ -410,7 +410,7 @@ template<typename P,
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
||||
// piCout << ">> vector trivial default";
|
||||
int sz = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || sz < 0) {
|
||||
fprintf(stderr, "error with PIVector<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
@@ -433,7 +433,7 @@ template<typename P,
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
||||
// piCout << ">> vector trivial custom";
|
||||
int sz = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || sz < 0) {
|
||||
fprintf(stderr, "error with PIVector<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
@@ -462,7 +462,7 @@ template<typename P,
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
||||
// piCout << ">> deque trivial default";
|
||||
int sz = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || sz < 0) {
|
||||
fprintf(stderr, "error with PIDeque<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
@@ -485,7 +485,7 @@ template<typename P,
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
||||
// piCout << ">> deque trivial custom";
|
||||
int sz = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || sz < 0) {
|
||||
fprintf(stderr, "error with PIDeque<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
@@ -516,7 +516,7 @@ inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIVector2D<T> & v)
|
||||
int r, c;
|
||||
r = s.binaryStreamTakeInt();
|
||||
c = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || r < 0 || c < 0) {
|
||||
fprintf(stderr, "error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
@@ -542,6 +542,11 @@ inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIVector2D<T> & v)
|
||||
PIVector<T> tmp;
|
||||
r = s.binaryStreamTakeInt();
|
||||
c = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError() || r < 0 || c < 0) {
|
||||
fprintf(stderr, "error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
}
|
||||
s >> tmp;
|
||||
if (s.wasReadError()) {
|
||||
fprintf(stderr, "error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
|
||||
@@ -618,7 +623,7 @@ template<typename P, typename T, typename std::enable_if<!std::is_trivially_copy
|
||||
//! \~russian Восстанавливает %PIVector из нетривиальных элементов по одному.
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
||||
int sz = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || sz < 0) {
|
||||
fprintf(stderr, "error with PIVector<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
@@ -641,7 +646,7 @@ template<typename P, typename T, typename std::enable_if<!std::is_trivially_copy
|
||||
//! \~russian Восстанавливает %PIDeque из нетривиальных элементов по одному.
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
||||
int sz = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || sz < 0) {
|
||||
fprintf(stderr, "error with PIDeque<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
@@ -667,6 +672,11 @@ inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIVector2D<T> & v)
|
||||
PIVector<T> tmp;
|
||||
r = s.binaryStreamTakeInt();
|
||||
c = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError() || r < 0 || c < 0) {
|
||||
fprintf(stderr, "error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
}
|
||||
s >> tmp;
|
||||
if (s.wasReadError()) {
|
||||
fprintf(stderr, "error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
|
||||
@@ -700,7 +710,7 @@ template<typename P, typename Key, typename T>
|
||||
//! \~russian Восстанавливает ключи и значения %PIMap.
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PIMap<Key, T> & v) {
|
||||
int sz = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || sz < 0) {
|
||||
fprintf(stderr, "error with PIMap<%s, %s>\n", __PIP_TYPENAME__(Key), __PIP_TYPENAME__(T));
|
||||
v.clear();
|
||||
return s;
|
||||
@@ -749,7 +759,7 @@ template<typename P, typename Key>
|
||||
//! \~russian Восстанавливает ключи %PISet.
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PISet<Key> & v) {
|
||||
int sz = s.binaryStreamTakeInt();
|
||||
if (s.wasReadError()) {
|
||||
if (s.wasReadError() || sz < 0) {
|
||||
fprintf(stderr, "error with PISet<%s>\n", __PIP_TYPENAME__(Key));
|
||||
v.clear();
|
||||
return s;
|
||||
|
||||
@@ -322,7 +322,7 @@ void PIProcess::startProc(bool detached) {
|
||||
if (!detached) PRIVATE->pid = pid_;
|
||||
if (pid_ == 0) {
|
||||
if (!wd.isEmpty()) {
|
||||
if (!chdir(wd.data())) piCoutObj << "Error while set working directory";
|
||||
if (chdir(wd.data()) != 0) piCoutObj << "Error while set working directory";
|
||||
}
|
||||
PRIVATE->closePipe(StdIn, PipeWrite);
|
||||
PRIVATE->closePipe(StdOut, PipeRead);
|
||||
|
||||
Reference in New Issue
Block a user