Lines 327-333
Link Here
|
327 |
gam_subscription_set_listener(sub, conn->listener); |
327 |
gam_subscription_set_listener(sub, conn->listener); |
328 |
gam_add_subscription(sub); |
328 |
gam_add_subscription(sub); |
329 |
break; |
329 |
break; |
330 |
case GAM_REQ_CANCEL: |
330 |
case GAM_REQ_CANCEL: { |
|
|
331 |
char *path; |
332 |
int pathlen; |
333 |
|
331 |
sub = |
334 |
sub = |
332 |
gam_listener_get_subscription_by_reqno(conn->listener, |
335 |
gam_listener_get_subscription_by_reqno(conn->listener, |
333 |
req->seq); |
336 |
req->seq); |
Lines 339-347
Link Here
|
339 |
} |
342 |
} |
340 |
GAM_DEBUG(DEBUG_INFO, "Cancelling subscription for (%d)\n", |
343 |
GAM_DEBUG(DEBUG_INFO, "Cancelling subscription for (%d)\n", |
341 |
req->seq); |
344 |
req->seq); |
|
|
345 |
path = g_strdup(gam_subscription_get_path(sub)); |
346 |
pathlen = gam_subscription_pathlen(sub); |
342 |
gam_remove_subscription(sub); |
347 |
gam_remove_subscription(sub); |
343 |
gam_listener_remove_subscription(conn->listener, sub); |
348 |
gam_listener_remove_subscription(conn->listener, sub); |
344 |
break; |
349 |
|
|
|
350 |
if (gam_send_ack(conn, req->seq, path, pathlen) < 0) { |
351 |
GAM_DEBUG(DEBUG_INFO, "Failed to send ack to PID %d\n", |
352 |
gam_connection_get_pid(conn)); |
353 |
} |
354 |
g_free(path); |
355 |
} break; |
345 |
case GAM_REQ_DEBUG: |
356 |
case GAM_REQ_DEBUG: |
346 |
#ifdef GAMIN_DEBUG_API |
357 |
#ifdef GAMIN_DEBUG_API |
347 |
gam_debug_add(conn, &req->path[0], options); |
358 |
gam_debug_add(conn, &req->path[0], options); |
Lines 543-549
Link Here
|
543 |
return (-1); |
554 |
return (-1); |
544 |
} |
555 |
} |
545 |
return (0); |
556 |
return (0); |
|
|
557 |
} |
546 |
|
558 |
|
|
|
559 |
/** |
560 |
* gam_send_ack: |
561 |
* @conn: the connection data |
562 |
* @path: the file/directory path |
563 |
* |
564 |
* Emit an acknowledge event to the connection |
565 |
* |
566 |
* Returns 0 in case of success and -1 in case of failure |
567 |
*/ |
568 |
int |
569 |
gam_send_ack(GamConnDataPtr conn, int reqno, |
570 |
const char *path, int len) |
571 |
{ |
572 |
GAMPacket req; |
573 |
size_t tlen; |
574 |
int ret; |
575 |
|
576 |
if ((conn == NULL) || (conn->fd < 0) || (path == NULL)) |
577 |
return (-1); |
578 |
|
579 |
if (len <= 0) { |
580 |
GAM_DEBUG(DEBUG_INFO, "Empty file path\n"); |
581 |
return (-1); |
582 |
} |
583 |
|
584 |
if (len >= MAXPATHLEN) { |
585 |
GAM_DEBUG(DEBUG_INFO, "File path too long %s\n", path); |
586 |
return (-1); |
587 |
} |
588 |
|
589 |
GAM_DEBUG(DEBUG_INFO, "Event to %d : %d, %d, %s\n", conn->pid, |
590 |
reqno, FAMAcknowledge, path); |
591 |
/* |
592 |
* prepare the packet |
593 |
*/ |
594 |
tlen = GAM_PACKET_HEADER_LEN + len; |
595 |
/* We use only local socket so no need for network byte order conversion */ |
596 |
req.len = (unsigned short) tlen; |
597 |
req.version = GAM_PROTO_VERSION; |
598 |
req.seq = reqno; |
599 |
req.type = FAMAcknowledge; |
600 |
req.pathlen = len; |
601 |
memcpy(&req.path[0], path, len); |
602 |
ret = |
603 |
gam_client_conn_write(conn->source, conn->fd, (gpointer) & req, |
604 |
tlen); |
605 |
if (!ret) { |
606 |
GAM_DEBUG(DEBUG_INFO, "Failed to send event to %d\n", conn->pid); |
607 |
return (-1); |
608 |
} |
609 |
return (0); |
547 |
} |
610 |
} |
548 |
|
611 |
|
549 |
/************************************************************************ |
612 |
/************************************************************************ |