Browse Source

Merge pull request #39 from jsorg71/mofd

use fd -1 not 0 for invalid fd
pull/50/head
jsorg71 4 years ago
committed by GitHub
parent
commit
e9f78c4f3a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      src/module-xrdp-sink.c

+ 7
- 5
src/module-xrdp-sink.c View File

@ -256,7 +256,7 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
struct header h; struct header h;
struct sockaddr_un s; struct sockaddr_un s;
if (u->fd == 0) {
if (u->fd == -1) {
if (u->failed_connect_time != 0) { if (u->failed_connect_time != 0) {
if (pa_rtclock_now() - u->failed_connect_time < 1000000) { if (pa_rtclock_now() - u->failed_connect_time < 1000000) {
return 0; return 0;
@ -307,7 +307,7 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
if (lsend(u->fd, (char*)(&h), 8) != 8) { if (lsend(u->fd, (char*)(&h), 8) != 8) {
pa_log("data_send: send failed"); pa_log("data_send: send failed");
close(u->fd); close(u->fd);
u->fd = 0;
u->fd = -1;
return 0; return 0;
} else { } else {
pa_log_debug("data_send: sent header ok bytes %d", bytes); pa_log_debug("data_send: sent header ok bytes %d", bytes);
@ -321,7 +321,7 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
if (sent != bytes) { if (sent != bytes) {
pa_log("data_send: send failed sent %d bytes %d", sent, bytes); pa_log("data_send: send failed sent %d bytes %d", sent, bytes);
close(u->fd); close(u->fd);
u->fd = 0;
u->fd = -1;
return 0; return 0;
} }
@ -332,7 +332,7 @@ static int close_send(struct userdata *u) {
struct header h; struct header h;
pa_log("close_send:"); pa_log("close_send:");
if (u->fd == 0) {
if (u->fd == -1) {
return 0; return 0;
} }
h.code = 1; h.code = 1;
@ -340,7 +340,7 @@ static int close_send(struct userdata *u) {
if (lsend(u->fd, (char*)(&h), 8) != 8) { if (lsend(u->fd, (char*)(&h), 8) != 8) {
pa_log("close_send: send failed"); pa_log("close_send: send failed");
close(u->fd); close(u->fd);
u->fd = 0;
u->fd = -1;
return 0; return 0;
} else { } else {
pa_log_debug("close_send: sent header ok"); pa_log_debug("close_send: sent header ok");
@ -497,6 +497,8 @@ int pa__init(pa_module*m) {
u->display_num = get_display_num_from_display(getenv("DISPLAY")); u->display_num = get_display_num_from_display(getenv("DISPLAY"));
u->fd = -1;
#if defined(PA_CHECK_VERSION) #if defined(PA_CHECK_VERSION)
#if PA_CHECK_VERSION(0, 9, 22) #if PA_CHECK_VERSION(0, 9, 22)
if (!(u->thread = pa_thread_new("xrdp-sink", thread_func, u))) { if (!(u->thread = pa_thread_new("xrdp-sink", thread_func, u))) {


Loading…
Cancel
Save