*/
#include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
return p;
}
-
-/*
- update a max latency number
- */
-void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t)
-{
- double l = timeval_elapsed(&t);
- if (l > *latency) {
- *latency = l;
- }
-
- if (ctdb_db->ctdb->tunable.log_latency_ms !=0) {
- if (l*1000 > ctdb_db->ctdb->tunable.log_latency_ms) {
- DEBUG(DEBUG_WARNING, ("High latency %fs for operation %s on database %s\n", l*1000000, name, ctdb_db->db_name));
- }
- }
-}
-
-/*
- update a reclock latency number
- */
-void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *latency, double l)
-{
- if (l > *latency) {
- *latency = l;
- }
-
- if (ctdb->tunable.reclock_latency_ms !=0) {
- if (l*1000 > ctdb->tunable.reclock_latency_ms) {
- DEBUG(DEBUG_ERR, ("High RECLOCK latency %fs for operation %s\n", l, name));
- }
- }
-}
-
uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state)
{
- uint32_t id;
-
- id = ctdb->idr_cnt++ & 0xFFFF;
- id |= (idr_get_new(ctdb->idr, state, 0xFFFF)<<16);
+ int id = idr_get_new_above(ctdb->idr, state, ctdb->lastid+1, INT_MAX);
+ if (id < 0) {
+ DEBUG(DEBUG_NOTICE, ("Reqid wrap!\n"));
+ id = idr_get_new(ctdb->idr, state, INT_MAX);
+ }
+ ctdb->lastid = id;
return id;
}
{
void *p;
- p = _idr_find_type(ctdb->idr, (reqid>>16)&0xFFFF, type, location);
+ p = _idr_find_type(ctdb->idr, reqid, type, location);
if (p == NULL) {
DEBUG(DEBUG_WARNING, ("Could not find idr:%u\n",reqid));
}
{
int ret;
- ret = idr_remove(ctdb->idr, (reqid>>16)&0xFFFF);
+ ret = idr_remove(ctdb->idr, reqid);
if (ret != 0) {
DEBUG(DEBUG_ERR, ("Removing idr that does not exist\n"));
}
}
}
+/*
+ make ourselves slightly nicer: eg. a ctdb child.
+ */
+void ctdb_reduce_priority(struct ctdb_context *ctdb)
+{
+ errno = 0;
+ if (nice(10) == -1 && errno != 0) {
+ DEBUG(DEBUG_WARNING,("Unable to lower priority: %s\n",
+ strerror(errno)));
+ }
+}
+
void set_nonblocking(int fd)
{
unsigned v;
return true;
}
-static bool parse_ipv6(const char *s, const char *iface, unsigned port, ctdb_sock_addr *saddr)
+static bool parse_ipv6(const char *s, const char *ifaces, unsigned port, ctdb_sock_addr *saddr)
{
saddr->ip6.sin6_family = AF_INET6;
saddr->ip6.sin6_port = htons(port);
return false;
}
- if (iface && IN6_IS_ADDR_LINKLOCAL(&saddr->ip6.sin6_addr)) {
- saddr->ip6.sin6_scope_id = if_nametoindex(iface);
+ if (ifaces && IN6_IS_ADDR_LINKLOCAL(&saddr->ip6.sin6_addr)) {
+ if (strchr(ifaces, ',')) {
+ DEBUG(DEBUG_ERR, (__location__ " Link local address %s "
+ "is specified for multiple ifaces %s\n",
+ s, ifaces));
+ return false;
+ }
+ saddr->ip6.sin6_scope_id = if_nametoindex(ifaces);
}
return true;
/*
parse an ip
*/
-bool parse_ip(const char *addr, const char *iface, unsigned port, ctdb_sock_addr *saddr)
+bool parse_ip(const char *addr, const char *ifaces, unsigned port, ctdb_sock_addr *saddr)
{
char *p;
bool ret;
if (p == NULL) {
ret = parse_ipv4(addr, port, &saddr->ip);
} else {
- ret = parse_ipv6(addr, iface, port, saddr);
+ ret = parse_ipv6(addr, ifaces, port, saddr);
}
return ret;
/*
parse a ip/mask pair
*/
-bool parse_ip_mask(const char *str, const char *iface, ctdb_sock_addr *addr, unsigned *mask)
+bool parse_ip_mask(const char *str, const char *ifaces, ctdb_sock_addr *addr, unsigned *mask)
{
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
char *s, *p;
/* now is this a ipv4 or ipv6 address ?*/
- ret = parse_ip(s, iface, 0, addr);
+ ret = parse_ip(s, ifaces, 0, addr);
talloc_free(tmp_ctx);
return ret;
}
const char *ctdb_eventscript_call_names[] = {
+ "init",
+ "setup",
"startup",
"startrecovery",
"recovered",
"monitor",
"status",
"shutdown",
- "reload"
+ "reload",
+ "updateip",
+ "ipreallocated"
};