Chimera: chimera_0-9/src/host.c File Reference

- Main Page
- Classes
- Files
- Directories

- File List
- File Members

# host.c File Reference

`#include <stdio.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <pthread.h>`
`#include <errno.h>`
`#include "host.h"`
`#include "network.h"`
`#include "message.h"`
`#include "log.h"`
`#include "dllist.h"`
`#include "jval.h"`
`#include "jrb.h"`

## Classes
struct | CacheEntry
struct | HostGlobal
## Functions
void | cacheentry_free (CacheEntry *entry)
void | host_encode (char *s, int len, ChimeraHost *host)
ChimeraHost * | host_decode (ChimeraState *state, char *s)
ChimeraHost * | host_get (ChimeraState *state, char *hostname, int port)
void | host_release (ChimeraState *state, ChimeraHost *host)
void | host_update_stat (ChimeraHost *host, int success)
void * | host_init (void *logs, int size)

## Function Documentation

void cacheentry_free | ( | CacheEntry * | entry | ) |

ChimeraHost* host_decode | ( | ChimeraState * | state,
|  | char * | s
| ) |

| host_decode: decodes a string into a chimera host structure. This acts as a host_get, and should be followed eventually by a host_release.

void host_encode | ( | char * | s,
|  | int | len,
|  | ChimeraHost * | host
| ) |

| host_encode: encodes the host# into a string, putting it in s#, which has len# bytes in it.

ChimeraHost* host_get | ( | ChimeraState * | state,
|  | char * | hostname,
|  | int | port
| ) |

| host_get: gets a host entry for the given host, getting it from the cache if possible, or alocates memory for it

void* host_init | ( | void * | logs,
|  | int | size
| ) |

| host_init: initialize a host struct with a size# element cache.

void host_release | ( | ChimeraState * | state,
|  | ChimeraHost * | host
| ) |

| host_release: releases a host from the cache, declaring that the memory could be freed any time. returns NULL if the entry is deleted, otherwise it returns host#

void host_update_stat | ( | ChimeraHost * | host,
|  | int | success
| ) |

| host_update_stat: updates the success rate to the host based on the SUCCESS_WINDOW average