/*
 * Cancel a monitor request.
 *
 * Raises a Fam::Error exception if the monitor request could not be
 * cancelled.
 *
 * Note: this method invalidates the specified monitor request.
 *
 * Aliases:
 *   Fam::Connection#cancel
 *
 * Examples:
 *   fam.cancel_monitor req
 *   fam.cancel req
 *
 */
static VALUE fam_conn_cancel(VALUE self, VALUE request)
{
  FAMConnection *conn;
  FAMRequest *req;
  int err;

  Data_Get_Struct(self, FAMConnection, conn);
  Data_Get_Struct(request, FAMRequest, req);
  err = FAMCancelMonitor(conn, req);

  if (err == -1) {
    rb_raise(eError, "Couldn't cancel monitor request %d: %s",
             FAMREQUEST_GETREQNUM(req), fam_error());
  }

  return self;
}