2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

Revert "ovsdb-data: New functions for predicting serialized length of data."

This reverts commit 0ea7bec76d.

Connections that queue up too much data, because they are monitoring a
table that is changing quickly and failing to keep up with the updates,
cause problems with buffer management.  Since commit 60533a405b
(jsonrpc-server: Disconnect connections that queue too much data.),
ovsdb-server has dealt with them by disconnecting the connection and
letting them start up again with a fresh copy of the database.  However,
this is not ideal because of situations where disconnection happens
repeatedly.  For example:

     - A manager toggles a column back and forth between two or more values
       quickly (in which case the data transmitted over the monitoring
       connections always increases quickly, without bound).

     - A manager repeatedly extends the contents of some column in some row
       (in which case the data transmitted over the monitoring connection
       grows with O(n**2) in the length of the string).

A better way to deal with this problem is to combine updates when they are
sent to the monitoring connection, if that connection is not keeping up.
In both the above cases, this reduces the data that must be sent to a
manageable amount.  An upcoming patch implements this new way.  This commit
reverts part of the previous solution that disconnects backlogged
connections, since it is no longer useful.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
This commit is contained in:
Ben Pfaff
2014-04-02 07:10:40 -07:00
parent 633f724799
commit 7bd02255d9
3 changed files with 5 additions and 108 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -467,47 +467,6 @@ ovsdb_atom_to_json(const union ovsdb_atom *atom, enum ovsdb_atomic_type type)
}
}
/* Returns strlen(json_to_string(ovsdb_atom_to_json(atom, type), 0)). */
size_t
ovsdb_atom_json_length(const union ovsdb_atom *atom,
enum ovsdb_atomic_type type)
{
struct json json;
switch (type) {
case OVSDB_TYPE_VOID:
OVS_NOT_REACHED();
case OVSDB_TYPE_INTEGER:
json.type = JSON_INTEGER;
json.u.integer = atom->integer;
break;
case OVSDB_TYPE_REAL:
json.type = JSON_REAL;
json.u.real = atom->real;
break;
case OVSDB_TYPE_BOOLEAN:
json.type = atom->boolean ? JSON_TRUE : JSON_FALSE;
break;
case OVSDB_TYPE_STRING:
json.type = JSON_STRING;
json.u.string = atom->string;
break;
case OVSDB_TYPE_UUID:
return strlen("[\"uuid\",\"00000000-0000-0000-0000-000000000000\"]");
case OVSDB_N_TYPES:
default:
OVS_NOT_REACHED();
}
return json_serialized_length(&json);
}
static char *
ovsdb_atom_from_string__(union ovsdb_atom *atom,
const struct ovsdb_base_type *base, const char *s,
@@ -1349,56 +1308,6 @@ ovsdb_datum_to_json(const struct ovsdb_datum *datum,
}
}
/* Returns strlen(json_to_string(ovsdb_datum_to_json(datum, type), 0)). */
size_t
ovsdb_datum_json_length(const struct ovsdb_datum *datum,
const struct ovsdb_type *type)
{
if (ovsdb_type_is_map(type)) {
size_t length;
/* ["map",[...]]. */
length = 10;
if (datum->n > 0) {
size_t i;
/* Commas between pairs in the inner [...] */
length += datum->n - 1;
/* [,] in each pair. */
length += datum->n * 3;
/* Data. */
for (i = 0; i < datum->n; i++) {
length += ovsdb_atom_json_length(&datum->keys[i],
type->key.type);
length += ovsdb_atom_json_length(&datum->values[i],
type->value.type);
}
}
return length;
} else if (datum->n == 1) {
return ovsdb_atom_json_length(&datum->keys[0], type->key.type);
} else {
size_t length;
size_t i;
/* ["set",[...]]. */
length = 10;
if (datum->n > 0) {
/* Commas between elements in the inner [...]. */
length += datum->n - 1;
/* Data. */
for (i = 0; i < datum->n; i++) {
length += ovsdb_atom_json_length(&datum->keys[i],
type->key.type);
}
}
return length;
}
}
static const char *
skip_spaces(const char *p)
{