EINTR recovery for BlenderConnection I/O

This commit is contained in:
Jack Andersen 2017-02-01 15:53:51 -10:00
parent 8469ee8fac
commit 1c9708f261
2 changed files with 45 additions and 7 deletions

View File

@ -337,7 +337,7 @@ def register():
bpy.types.Object.retro_textpane_font_path = bpy.props.StringProperty(name='Retro: Font Path')
bpy.types.Object.retro_textpane_word_wrap = bpy.props.BoolProperty(name='Retro: Word Wrap')
bpy.types.Object.retro_textpane_horizontal = bpy.props.BoolProperty(name='Retro: Horizontal')
bpy.types.Object.retro_textpane_horizontal = bpy.props.BoolProperty(name='Retro: Horizontal', default=True)
bpy.types.Object.retro_textpane_fill_color = bpy.props.FloatVectorProperty(name='Retro: Fill Color', min=0.0, max=1.0, size=4, subtype='COLOR')
bpy.types.Object.retro_textpane_outline_color = bpy.props.FloatVectorProperty(name='Retro: Outline Color', min=0.0, max=1.0, size=4, subtype='COLOR')
bpy.types.Object.retro_textpane_block_extent = bpy.props.FloatVectorProperty(name='Retro: Block Extent', min=0.0, size=2)

View File

@ -83,10 +83,48 @@ static void InstallStartup(const char* path)
fclose(fp);
}
static int Read(int fd, void* buf, size_t size)
{
int intrCount = 0;
do
{
auto ret = read(fd, buf, size);
if (ret < 0)
{
if (errno == EINTR)
++intrCount;
else
return -1;
}
else
return ret;
} while (intrCount < 3);
return -1;
}
static int Write(int fd, const void* buf, size_t size)
{
int intrCount = 0;
do
{
auto ret = write(fd, buf, size);
if (ret < 0)
{
if (errno == EINTR)
++intrCount;
else
return -1;
}
else
return ret;
} while (intrCount < 3);
return -1;
}
uint32_t BlenderConnection::_readStr(char* buf, uint32_t bufSz)
{
uint32_t readLen;
int ret = read(m_readpipe[0], &readLen, 4);
int ret = Read(m_readpipe[0], &readLen, 4);
if (ret < 4)
{
_blenderDied();
@ -100,7 +138,7 @@ uint32_t BlenderConnection::_readStr(char* buf, uint32_t bufSz)
return 0;
}
ret = read(m_readpipe[0], buf, readLen);
ret = Read(m_readpipe[0], buf, readLen);
if (ret < 0)
{
BlenderLog.report(logvisor::Fatal, strerror(errno));
@ -122,10 +160,10 @@ uint32_t BlenderConnection::_readStr(char* buf, uint32_t bufSz)
uint32_t BlenderConnection::_writeStr(const char* buf, uint32_t len, int wpipe)
{
int ret, nlerr;
nlerr = write(wpipe, &len, 4);
nlerr = Write(wpipe, &len, 4);
if (nlerr < 4)
goto err;
ret = write(wpipe, buf, len);
ret = Write(wpipe, buf, len);
if (ret < 0)
goto err;
return (uint32_t)ret;
@ -136,7 +174,7 @@ err:
size_t BlenderConnection::_readBuf(void* buf, size_t len)
{
int ret = read(m_readpipe[0], buf, len);
int ret = Read(m_readpipe[0], buf, len);
if (ret < 0)
goto err;
if (len >= 4)
@ -150,7 +188,7 @@ err:
size_t BlenderConnection::_writeBuf(const void* buf, size_t len)
{
int ret = write(m_writepipe[1], buf, len);
int ret = Write(m_writepipe[1], buf, len);
if (ret < 0)
goto err;
return ret;