Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 67170
Collapse All | Expand All

(-)gamin-0.0.26.orig/libgamin/gam_api.c (-11 lines)
Lines 1300-1306 Link Here
1300
int
1300
int
1301
FAMCancelMonitor(FAMConnection * fc, const FAMRequest * fr)
1301
FAMCancelMonitor(FAMConnection * fc, const FAMRequest * fr)
1302
{
1302
{
1303
    GAMDataPtr conn;
1304
    int ret;
1303
    int ret;
1305
1304
1306
    if ((fc == NULL) || (fr == NULL)) {
1305
    if ((fc == NULL) || (fr == NULL)) {
Lines 1317-1332 Link Here
1317
    GAM_DEBUG(DEBUG_INFO, "FAMCancelMonitor(%d)\n", fr->reqnum);
1316
    GAM_DEBUG(DEBUG_INFO, "FAMCancelMonitor(%d)\n", fr->reqnum);
1318
1317
1319
    /*
1318
    /*
1320
     * destroy the request internally
1321
     */
1322
    conn = fc->client;
1323
    ret = gamin_data_del_req(conn, fr->reqnum);
1324
    if (ret < 0) {
1325
        FAMErrno = FAM_ARG;
1326
        return (-1);
1327
    }
1328
1329
    /*
1330
     * send destruction message to the server
1319
     * send destruction message to the server
1331
     */
1320
     */
1332
    ret = gamin_send_request(GAM_REQ_CANCEL, fc->fd, NULL,
1321
    ret = gamin_send_request(GAM_REQ_CANCEL, fc->fd, NULL,
(-)gamin-0.0.26.orig/libgamin/gam_data.c (+6 lines)
Lines 458-463 Link Here
458
    event->code = evn->type;
458
    event->code = evn->type;
459
    conn->evn_ready = 0;
459
    conn->evn_ready = 0;
460
    conn->evn_read -= evn->len;
460
    conn->evn_read -= evn->len;
461
    if (event->code == FAMAcknowledge) {
462
        /*
463
         * destroy the request internally
464
         */
465
        gamin_data_del_req(conn, evn->seq);
466
    }
461
    if (conn->evn_read > 0) {
467
    if (conn->evn_read > 0) {
462
        /*
468
        /*
463
         * there was other events piggy-backed on the same read,
469
         * there was other events piggy-backed on the same read,
(-)gamin-0.0.26.orig/server/gam_connection.c (-2 / +65 lines)
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
/************************************************************************
(-)gamin-0.0.26.orig/server/gam_connection.h (+4 lines)
Lines 47-52 Link Here
47
					 int event,
47
					 int event,
48
					 const char *path,
48
					 const char *path,
49
					 int len);
49
					 int len);
50
int		gam_send_ack		(GamConnDataPtr conn,
51
					 int reqno,
52
					 const char *path,
53
					 int len);
50
void		gam_connections_debug	(void);
54
void		gam_connections_debug	(void);
51
#ifdef __cplusplus
55
#ifdef __cplusplus
52
}
56
}

Return to bug 67170