show an actual error if we ever run out of FDs (thanks rob pike)
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
bd97cc23da
commit
6de65dfe87
1 changed files with 8 additions and 4 deletions
|
|
@ -55,24 +55,28 @@ void MwLLWaylandBackbufferDestroy(struct _MwLLWayland* wayland) {
|
||||||
|
|
||||||
void MwLLWaylandBufferSetup(struct _MwLLWaylandShmBuffer* buffer, MwU32 width, MwU32 height) {
|
void MwLLWaylandBufferSetup(struct _MwLLWaylandShmBuffer* buffer, MwU32 width, MwU32 height) {
|
||||||
int stride = width * 4;
|
int stride = width * 4;
|
||||||
char temp_name[] = "/tmp/milsko-wl-shm-XXXXXX";
|
char temp_name[] = "/tmp/milsko-wl-shm-XXXXXXXX";
|
||||||
char temp_name_back[] = "/tmp/milsko-wl-shm-back-XXXXXX";
|
char temp_name_back[] = "/tmp/milsko-wl-shm-back-XXXXXXXX";
|
||||||
|
|
||||||
buffer->buf_size = width * height * 4;
|
buffer->buf_size = width * height * 4;
|
||||||
|
|
||||||
buffer->fd = mkstemp(temp_name);
|
buffer->fd = mkstemp(temp_name);
|
||||||
buffer->fd_back = mkstemp(temp_name_back);
|
buffer->fd_back = mkstemp(temp_name_back);
|
||||||
|
if(buffer->fd >= FD_SETSIZE - 1) {
|
||||||
|
MwDispatchError(-1, "Amount of allocated buffers has reached FD_SETSIZE! Cannot continue.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unlink(temp_name);
|
unlink(temp_name);
|
||||||
unlink(temp_name_back);
|
unlink(temp_name_back);
|
||||||
|
|
||||||
if(posix_fallocate(buffer->fd, 0, buffer->buf_size) != 0) {
|
if(posix_fallocate(buffer->fd, 0, buffer->buf_size) != 0) {
|
||||||
printf("failure setting up wl_shm: could not fallocate. %s.\n", strerror(errno));
|
printf("failure setting up wl_shm (front buf): could not fallocate. %s.\n", strerror(errno));
|
||||||
close(buffer->fd);
|
close(buffer->fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(posix_fallocate(buffer->fd_back, 0, buffer->buf_size) != 0) {
|
if(posix_fallocate(buffer->fd_back, 0, buffer->buf_size) != 0) {
|
||||||
printf("failure setting up wl_shm: could not fallocate. %s.\n", strerror(errno));
|
printf("failure setting up wl_shm (back buf): could not fallocate. %s.\n", strerror(errno));
|
||||||
close(buffer->fd_back);
|
close(buffer->fd_back);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue