|
|
@ -1,6 +1,7 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdbool.h> |
|
|
|
#include <stdbool.h> |
|
|
|
#include <unistd.h> |
|
|
|
#include <unistd.h> |
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
|
#include <sys/types.h> |
|
|
|
#include <sys/types.h> |
|
|
|
#include <sys/socket.h> |
|
|
|
#include <sys/socket.h> |
|
|
|
#include <netinet/in.h> |
|
|
|
#include <netinet/in.h> |
|
|
@ -77,26 +78,20 @@ int wait_for_socket_read(int sock) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main(void) |
|
|
|
int run_renderer(int new_fd) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int sock, new_fd, ret; |
|
|
|
int ret; |
|
|
|
uint32_t header[VTEST_HDR_SIZE]; |
|
|
|
uint32_t header[VTEST_HDR_SIZE]; |
|
|
|
static int fence_id = 1; |
|
|
|
|
|
|
|
bool do_fence; |
|
|
|
bool do_fence; |
|
|
|
sock = vtest_open_socket("/tmp/.virgl_test"); |
|
|
|
|
|
|
|
restart: |
|
|
|
|
|
|
|
new_fd = wait_for_socket_accept(sock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vtest_create_renderer(new_fd); |
|
|
|
vtest_create_renderer(new_fd); |
|
|
|
again: |
|
|
|
again: |
|
|
|
ret = wait_for_socket_read(new_fd); |
|
|
|
ret = wait_for_socket_read(new_fd); |
|
|
|
if (ret < 0) |
|
|
|
if (ret < 0) |
|
|
|
goto err; |
|
|
|
goto fail; |
|
|
|
|
|
|
|
|
|
|
|
ret = vtest_block_read(new_fd, &header, sizeof(header)); |
|
|
|
ret = vtest_block_read(new_fd, &header, sizeof(header)); |
|
|
|
|
|
|
|
|
|
|
|
if (ret == 8) { |
|
|
|
if (ret == 8) { |
|
|
|
fprintf(stderr, "got length: %d cmd: %d\n", header[0], header[1]); |
|
|
|
|
|
|
|
vtest_poll(); |
|
|
|
vtest_poll(); |
|
|
|
do_fence = false; |
|
|
|
do_fence = false; |
|
|
|
switch (header[1]) { |
|
|
|
switch (header[1]) { |
|
|
@ -127,10 +122,7 @@ again: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (ret < 0) { |
|
|
|
if (ret < 0) { |
|
|
|
fprintf(stderr, "socket failed - relistening\n"); |
|
|
|
goto fail; |
|
|
|
close(new_fd); |
|
|
|
|
|
|
|
vtest_destroy_renderer(); |
|
|
|
|
|
|
|
goto restart; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (do_fence) |
|
|
|
if (do_fence) |
|
|
@ -138,12 +130,32 @@ again: |
|
|
|
goto again; |
|
|
|
goto again; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ret <= 0) { |
|
|
|
if (ret <= 0) { |
|
|
|
fprintf(stderr, "socket failed - relistening\n"); |
|
|
|
goto fail; |
|
|
|
close(new_fd); |
|
|
|
} |
|
|
|
|
|
|
|
fail: |
|
|
|
|
|
|
|
fprintf(stderr, "socket failed - closing renderer\n"); |
|
|
|
vtest_destroy_renderer(); |
|
|
|
vtest_destroy_renderer(); |
|
|
|
goto restart; |
|
|
|
close(new_fd); |
|
|
|
|
|
|
|
exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
err: |
|
|
|
|
|
|
|
|
|
|
|
int main(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int sock, new_fd, ret; |
|
|
|
|
|
|
|
pid_t pid; |
|
|
|
|
|
|
|
sock = vtest_open_socket("/tmp/.virgl_test"); |
|
|
|
|
|
|
|
restart: |
|
|
|
|
|
|
|
new_fd = wait_for_socket_accept(sock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* fork a renderer process */ |
|
|
|
|
|
|
|
switch ((pid = fork())) { |
|
|
|
|
|
|
|
case 0: |
|
|
|
|
|
|
|
run_renderer(new_fd); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case -1: |
|
|
|
|
|
|
|
default: |
|
|
|
close(new_fd); |
|
|
|
close(new_fd); |
|
|
|
|
|
|
|
goto restart; |
|
|
|
|
|
|
|
} |
|
|
|
close(sock); |
|
|
|
close(sock); |
|
|
|
} |
|
|
|
} |
|
|
|