Changeset 192565b in mainline for uspace/srv


Ignore:
Timestamp:
2013-05-27T13:18:13Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f2c19b0
Parents:
d120133 (diff), c90aed4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
uspace/srv
Files:
9 added
1 deleted
25 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/main.c

    rd120133 r192565b  
    735735{
    736736        client_t *client;
    737         driver_t *driver;
     737        driver_t *driver = NULL;
    738738       
    739739        /* Accept the connection. */
  • uspace/srv/fs/cdfs/cdfs_ops.c

    rd120133 r192565b  
    660660         */
    661661        if ((vol_desc->type != VOL_DESC_PRIMARY) ||
    662             (bcmp(vol_desc->standard_ident, CDFS_STANDARD_IDENT, 5) != 0) ||
     662            (memcmp(vol_desc->standard_ident, CDFS_STANDARD_IDENT, 5) != 0) ||
    663663            (vol_desc->version != 1)) {
    664664                block_put(block);
  • uspace/srv/fs/fat/fat_dentry.c

    rd120133 r192565b  
    4444#include <assert.h>
    4545#include <unistd.h>
     46#include <sys/types.h>
    4647
    4748/** Compare path component with the name read from the dentry.
     
    232233/** Get number of bytes in a string with size limit.
    233234 *
    234  * @param str  NULL-terminated (or not) string.
     235 * @param str  NULL-terminated (or not) string. The pointer comes from a packed
     236 *             structure and as such is expected to be unaligned.
    235237 * @param size Maximum number of bytes to consider.
    236238 *
     
    238240 *
    239241 */
    240 size_t fat_lfn_str_nlength(const uint16_t *str, size_t size)
     242size_t fat_lfn_str_nlength(const unaligned_uint16_t *str, size_t size)
    241243{
    242244        size_t offset = 0;
  • uspace/srv/fs/fat/fat_dentry.h

    rd120133 r192565b  
    3737#include <stdint.h>
    3838#include <stdbool.h>
     39#include <sys/types.h>
    3940
    4041#define IS_D_CHAR(ch) (isalnum(ch) || ch == '_')
     
    132133} __attribute__ ((packed)) fat_dentry_t;
    133134
    134 
    135135extern int fat_dentry_namecmp(char *, const char *);
    136136extern void fat_dentry_name_get(const fat_dentry_t *, char *);
     
    139139extern uint8_t fat_dentry_chksum(uint8_t *);
    140140
    141 extern size_t fat_lfn_str_nlength(const uint16_t *, size_t);
     141extern size_t fat_lfn_str_nlength(const unaligned_uint16_t *, size_t);
    142142extern size_t fat_lfn_size(const fat_dentry_t *);
    143143extern size_t fat_lfn_get_entry(const fat_dentry_t *, uint16_t *, size_t *);
  • uspace/srv/fs/fat/fat_directory.c

    rd120133 r192565b  
    516516                        return false;
    517517                case FAT_DENTRY_VALID:
    518                         if (bcmp(de->name, d->name,
    519                             FAT_NAME_LEN + FAT_EXT_LEN)==0)
     518                        if (memcmp(de->name, d->name,
     519                            FAT_NAME_LEN + FAT_EXT_LEN) == 0)
    520520                                return true;
    521521                        break;
  • uspace/srv/fs/fat/fat_ops.c

    rd120133 r192565b  
    651651                d = (fat_dentry_t *) b->data;
    652652                if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) ||
    653                     (bcmp(d->name, FAT_NAME_DOT, FAT_NAME_LEN)) == 0) {
     653                    (memcmp(d->name, FAT_NAME_DOT, FAT_NAME_LEN)) == 0) {
    654654                        memset(d, 0, sizeof(fat_dentry_t));
    655655                        memcpy(d->name, FAT_NAME_DOT, FAT_NAME_LEN);
     
    661661                d++;
    662662                if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) ||
    663                     (bcmp(d->name, FAT_NAME_DOT_DOT, FAT_NAME_LEN) == 0)) {
     663                    (memcmp(d->name, FAT_NAME_DOT_DOT, FAT_NAME_LEN) == 0)) {
    664664                        memset(d, 0, sizeof(fat_dentry_t));
    665665                        memcpy(d->name, FAT_NAME_DOT_DOT, FAT_NAME_LEN);
     
    10421042        info = (fat32_fsinfo_t *) b->data;
    10431043
    1044         if (bcmp(info->sig1, FAT32_FSINFO_SIG1, sizeof(info->sig1)) ||
    1045             bcmp(info->sig2, FAT32_FSINFO_SIG2, sizeof(info->sig2)) ||
    1046             bcmp(info->sig3, FAT32_FSINFO_SIG3, sizeof(info->sig3))) {
     1044        if (memcmp(info->sig1, FAT32_FSINFO_SIG1, sizeof(info->sig1)) != 0 ||
     1045            memcmp(info->sig2, FAT32_FSINFO_SIG2, sizeof(info->sig2)) != 0 ||
     1046            memcmp(info->sig3, FAT32_FSINFO_SIG3, sizeof(info->sig3)) != 0) {
    10471047                (void) block_put(b);
    10481048                return EINVAL;
  • uspace/srv/fs/mfs/mfs_dentry.c

    rd120133 r192565b  
    178178
    179179                if (name_len == d_name_len &&
    180                     !bcmp(d_info.d_name, d_name, name_len)) {
     180                    memcmp(d_info.d_name, d_name, name_len) == 0) {
    181181
    182182                        d_info.d_inum = 0;
  • uspace/srv/fs/mfs/mfs_ops.c

    rd120133 r192565b  
    452452
    453453                if (comp_size == dentry_name_size &&
    454                     !bcmp(component, d_info.d_name, dentry_name_size)) {
     454                    memcmp(component, d_info.d_name, dentry_name_size) == 0) {
    455455                        /* Hit! */
    456456                        mfs_node_core_get(rfn, mnode->instance,
  • uspace/srv/fs/udf/udf_volume.c

    rd120133 r192565b  
    262262                 * and Descriptor char set field.
    263263                 */
    264                 if ((bcmp((uint8_t *) pvd[i].volume_id,
     264                if ((memcmp((uint8_t *) pvd[i].volume_id,
    265265                    (uint8_t *) desc->volume_id, 32) == 0) &&
    266                     (bcmp((uint8_t *) pvd[i].volume_set_id,
     266                    (memcmp((uint8_t *) pvd[i].volume_set_id,
    267267                    (uint8_t *) desc->volume_set_id, 128) == 0) &&
    268                     (bcmp((uint8_t *) &pvd[i].descriptor_charset,
     268                    (memcmp((uint8_t *) &pvd[i].descriptor_charset,
    269269                    (uint8_t *) &desc->descriptor_charset, 64) == 0) &&
    270270                    (FLE32(desc->sequence_number) > FLE32(pvd[i].sequence_number))) {
     
    301301                 * Logic Volume Identifier and Descriptor char set field.
    302302                 */
    303                 if ((bcmp((uint8_t *) lvd[i].logical_volume_id,
     303                if ((memcmp((uint8_t *) lvd[i].logical_volume_id,
    304304                    (uint8_t *) desc->logical_volume_id, 128) == 0) &&
    305                     (bcmp((uint8_t *) &lvd[i].charset,
     305                    (memcmp((uint8_t *) &lvd[i].charset,
    306306                    (uint8_t *) &desc->charset, 64) == 0) &&
    307307                    (FLE32(desc->sequence_number) > FLE32(lvd[i].sequence_number))) {
  • uspace/srv/hid/compositor/Makefile

    rd120133 r192565b  
    3838
    3939IMAGES = \
    40         gfx/helenos.tga \
    4140        gfx/nameic.tga
    4241
  • uspace/srv/hid/compositor/compositor.c

    rd120133 r192565b  
    9090typedef struct {
    9191        link_t link;
     92        atomic_t ref_cnt;
    9293        service_id_t in_dsid;
    9394        service_id_t out_dsid;
     
    138139} viewport_t;
    139140
     141static desktop_rect_t viewport_bound_rect;
    140142static FIBRIL_MUTEX_INITIALIZE(viewport_list_mtx);
    141143static LIST_INITIALIZE(viewport_list);
     
    215217
    216218        link_initialize(&win->link);
     219        atomic_set(&win->ref_cnt, 0);
    217220        prodcons_initialize(&win->queue);
    218221        transform_identity(&win->transform);
     
    232235static void window_destroy(window_t *win)
    233236{
    234         if (win) {
     237        if (win && atomic_get(&win->ref_cnt) == 0) {
     238                while (!list_empty(&win->queue.list)) {
     239                        window_event_t *event = (window_event_t *) list_first(&win->queue.list);
     240                        list_remove(&event->link);
     241                        free(event);
     242                }
     243
    235244                if (win->surface) {
    236245                        surface_destroy(win->surface);
     
    310319}
    311320
     321static void comp_restrict_pointers(void)
     322{
     323        fibril_mutex_lock(&viewport_list_mtx);
     324
     325        sysarg_t x_res = coord_origin;
     326        sysarg_t y_res = coord_origin;
     327        sysarg_t w_res = 0;
     328        sysarg_t h_res = 0;
     329
     330        if (!list_empty(&viewport_list)) {
     331                viewport_t *vp = (viewport_t *) list_first(&viewport_list);
     332                x_res = vp->pos.x;
     333                y_res = vp->pos.y;
     334                surface_get_resolution(vp->surface, &w_res, &h_res);
     335        }
     336
     337        list_foreach(viewport_list, link) {
     338                viewport_t *vp = list_get_instance(link, viewport_t, link);
     339                sysarg_t w_vp, h_vp;
     340                surface_get_resolution(vp->surface, &w_vp, &h_vp);
     341                rectangle_union(
     342                    x_res, y_res, w_res, h_res,
     343                    vp->pos.x, vp->pos.y, w_vp, h_vp,
     344                    &x_res, &y_res, &w_res, &h_res);
     345        }
     346
     347        viewport_bound_rect.x = x_res;
     348        viewport_bound_rect.y = y_res;
     349        viewport_bound_rect.w = w_res;
     350        viewport_bound_rect.h = h_res;
     351
     352        fibril_mutex_unlock(&viewport_list_mtx);
     353
     354        fibril_mutex_lock(&pointer_list_mtx);
     355
     356        list_foreach(pointer_list, link) {
     357                pointer_t *ptr = list_get_instance(link, pointer_t, link);
     358                ptr->pos.x = ptr->pos.x > viewport_bound_rect.x ? ptr->pos.x : viewport_bound_rect.x;
     359                ptr->pos.y = ptr->pos.y > viewport_bound_rect.y ? ptr->pos.y : viewport_bound_rect.y;
     360                ptr->pos.x = ptr->pos.x < viewport_bound_rect.x + viewport_bound_rect.w ?
     361                    ptr->pos.x : viewport_bound_rect.x + viewport_bound_rect.w;
     362                ptr->pos.y = ptr->pos.y < viewport_bound_rect.y + viewport_bound_rect.h ?
     363                    ptr->pos.y : viewport_bound_rect.y + viewport_bound_rect.h;
     364        }
     365
     366        fibril_mutex_unlock(&pointer_list_mtx);
     367}
     368
    312369static void comp_damage(sysarg_t x_dmg_glob, sysarg_t y_dmg_glob,
    313370    sysarg_t w_dmg_glob, sysarg_t h_dmg_glob)
     
    695752        }
    696753
     754        loc_service_unregister(win->in_dsid);
     755        loc_service_unregister(win->out_dsid);
     756
     757        /* In case the client was killed, input fibril of the window might be
     758         * still blocked on the condition within comp_window_get_event. */
     759        window_event_t *event_dummy = (window_event_t *) malloc(sizeof(window_event_t));
     760        if (event_dummy) {
     761                link_initialize(&event_dummy->link);
     762                prodcons_produce(&win->queue, &event_dummy->link);
     763        }
     764
    697765        /* Calculate damage. */
    698766        sysarg_t x = 0;
     
    706774        }
    707775
    708         /* Release window resources. */
    709         loc_service_unregister(win->in_dsid);
    710         loc_service_unregister(win->out_dsid);
    711         while (!list_empty(&win->queue.list)) {
    712                 list_remove(list_first(&win->queue.list));
    713         }
    714         window_destroy(win);
    715 
    716776        comp_damage(x, y, width, height);
    717777
     
    813873
    814874        if (win) {
     875                atomic_inc(&win->ref_cnt);
    815876                async_answer_0(iid, EOK);
    816877        } else {
     
    825886
    826887                        if (!IPC_GET_IMETHOD(call)) {
    827                                 async_answer_0(callid, EINVAL);
     888                                async_answer_0(callid, EOK);
     889                                atomic_dec(&win->ref_cnt);
     890                                window_destroy(win);
    828891                                return;
    829892                        }
     
    842905
    843906                        if (!IPC_GET_IMETHOD(call)) {
    844                                 async_answer_0(callid, EINVAL);
     907                                comp_window_close(win, callid, &call);
     908                                atomic_dec(&win->ref_cnt);
     909                                window_destroy(win);
    845910                                return;
    846911                        }
     
    857922                                break;
    858923                        case WINDOW_CLOSE:
    859                                 comp_window_close(win, callid, &call);
     924                                /* Postpone the closing until the phone is hung up to cover
     925                                 * the case when the client is killed abruptly. */
     926                                async_answer_0(callid, EOK);
    860927                                break;
    861928                        case WINDOW_CLOSE_REQUEST:
     
    911978        async_answer_0(iid, EOK);
    912979
     980        comp_restrict_pointers();
    913981        comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    914982}
     
    9561024                fibril_mutex_unlock(&viewport_list_mtx);
    9571025                async_answer_0(iid, EOK);
     1026
     1027                comp_restrict_pointers();
     1028                comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    9581029        }
    9591030}
     
    13911462        surface_get_resolution(pointer->cursor.states[pointer->state],
    13921463             &cursor_width, &cursor_height);
     1464        if (pointer->pos.x + dx < viewport_bound_rect.x) {
     1465                dx = -1 * (pointer->pos.x - viewport_bound_rect.x);
     1466        }
     1467        if (pointer->pos.y + dy < viewport_bound_rect.y) {
     1468                dy = -1 * (pointer->pos.y - viewport_bound_rect.y);
     1469        }
     1470        if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) {
     1471                dx = (viewport_bound_rect.x + viewport_bound_rect.w - pointer->pos.x);
     1472        }
     1473        if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) {
     1474                dy = (viewport_bound_rect.y + viewport_bound_rect.h - pointer->pos.y);
     1475        }
    13931476        pointer->pos.x += dx;
    13941477        pointer->pos.y += dy;
     
    19101993                        fibril_mutex_unlock(&viewport_list_mtx);
    19111994
     1995                        comp_restrict_pointers();
    19121996                        comp_damage(x, y, width, height);
    19131997                } else {
     
    19622046                }
    19632047                list_prepend(&blue_win->link, &window_list);
    1964 
    1965                 window_t *helenos_win = window_create(0, 0);
    1966                 helenos_win->surface = decode_tga((void *) helenos_tga, helenos_tga_size, 0);
    1967                 list_prepend(&helenos_win->link, &window_list);
    1968 
     2048               
    19692049                window_t *nameic_win = window_create(0, 0);
    19702050                nameic_win->surface = decode_tga((void *) nameic_tga, nameic_tga_size, 0);
     
    21312211                return -1;
    21322212        }
    2133        
     2213
     2214        comp_restrict_pointers();
    21342215        comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    21352216       
  • uspace/srv/hid/console/console.c

    rd120133 r192565b  
    129129static void cons_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
    130130static void cons_set_cursor_visibility(con_srv_t *, bool);
    131 static int cons_get_event(con_srv_t *, kbd_event_t *);
     131static int cons_get_event(con_srv_t *, cons_event_t *);
    132132
    133133static con_ops_t con_ops = {
     
    490490}
    491491
    492 static int cons_get_event(con_srv_t *srv, kbd_event_t *event)
     492static int cons_get_event(con_srv_t *srv, cons_event_t *event)
    493493{
    494494        console_t *cons = srv_to_console(srv);
     
    496496        kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
    497497       
    498         *event = *kevent;
     498        event->type = CEV_KEY;
     499        event->ev.key = *kevent;
    499500        free(kevent);
    500501        return EOK;
  • uspace/srv/hid/remcons/remcons.c

    rd120133 r192565b  
    8080static int remcons_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
    8181static int remcons_get_color_cap(con_srv_t *, console_caps_t *);
    82 static int remcons_get_event(con_srv_t *, kbd_event_t *);
     82static int remcons_get_event(con_srv_t *, cons_event_t *);
    8383
    8484static con_ops_t con_ops = {
     
    185185}
    186186
    187 static int remcons_get_event(con_srv_t *srv, kbd_event_t *event)
    188 {
    189         telnet_user_t *user = srv_to_user(srv);
     187static int remcons_get_event(con_srv_t *srv, cons_event_t *event)
     188{
     189        telnet_user_t *user = srv_to_user(srv);
     190        kbd_event_t kevent;
    190191        int rc;
    191192
    192         rc = telnet_user_get_next_keyboard_event(user, event);
     193        rc = telnet_user_get_next_keyboard_event(user, &kevent);
    193194        if (rc != EOK) {
    194195                /* XXX What? */
     
    196197                return EOK;
    197198        }
     199
     200        event->type = CEV_KEY;
     201        event->ev.key = kevent;
    198202
    199203        return EOK;
  • uspace/srv/net/dnsrsrv/query.h

    rd120133 r192565b  
    11/*
    2  * Copyright (c) 2008 Martin Decky
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup genarch
     29/** @addtogroup dnsres
    3030 * @{
    3131 */
    32 /** @file
     32/**
     33 * @file
    3334 */
    3435
    35 #ifndef KERN_LOGO_196X66_H_
    36 #define KERN_LOGO_196X66_H_
     36#ifndef QUERY_H
     37#define QUERY_H
    3738
    38 #define LOGO_WIDTH   196
    39 #define LOGO_HEIGHT  66
    40 #define LOGO_COLOR   0xffffff
     39#include "dns_type.h"
    4140
    42 #include <typedefs.h>
    43 
    44 extern uint32_t fb_logo[LOGO_WIDTH * LOGO_HEIGHT];
     41extern int dns_name2host(const char *, dns_host_info_t **);
     42extern void dns_hostinfo_destroy(dns_host_info_t *);
    4543
    4644#endif
  • uspace/srv/net/ethip/ethip.c

    rd120133 r192565b  
    221221        case ETYPE_IP:
    222222                log_msg(LOG_DEFAULT, LVL_DEBUG, " - construct SDU");
    223                 sdu.lsrc.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 1;
    224                 sdu.ldest.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 4;
     223                sdu.lsrc.ipv4 = 0;
     224                sdu.ldest.ipv4 = 0;
    225225                sdu.data = frame.data;
    226226                sdu.size = frame.size;
  • uspace/srv/net/inetsrv/addrobj.c

    rd120133 r192565b  
    221221
    222222        lsrc_addr.ipv4 = addr->naddr.ipv4;
    223         ldest_addr = &dgram->dest;
     223        ldest_addr = ldest;
    224224
    225225        return inet_link_send_dgram(addr->ilink, &lsrc_addr, ldest_addr, dgram,
  • uspace/srv/net/inetsrv/inet_link.c

    rd120133 r192565b  
    196196
    197197        static int first = 1;
    198         /* XXX For testing: set static IP address 192.168.0.4/24 */
     198        /* XXX For testing: set static IP address 10.0.2.15/24 */
    199199        addr = inet_addrobj_new();
    200200        if (first) {
     
    202202                first = 0;
    203203        } else {
    204                 addr->naddr.ipv4 = (192 << 24) + (168 << 16) + (0 << 8) + 4;
     204                addr->naddr.ipv4 = (10 << 24) + (0 << 16) + (2 << 8) + 15;
    205205        }
    206206        addr->naddr.bits = 24;
  • uspace/srv/net/inetsrv/inetsrv.c

    rd120133 r192565b  
    9898        }
    9999       
    100         rc = inet_link_discovery_start();
     100        inet_sroute_t *sroute = inet_sroute_new();
     101        if (sroute == NULL) {
     102                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed creating default route (%d).", rc);
     103                return ENOMEM;
     104        }
     105
     106        sroute->dest.ipv4 = 0;
     107        sroute->dest.bits = 0;
     108        sroute->router.ipv4 = (10 << 24) | (0 << 16) | (2 << 8) | 2;
     109        sroute->name = str_dup("default");
     110        inet_sroute_add(sroute);
     111
     112        rc = inet_link_discovery_start();
    101113        if (rc != EOK)
    102114                return EEXIST;
  • uspace/srv/net/inetsrv/inetsrv.h

    rd120133 r192565b  
    4040#include <adt/list.h>
    4141#include <stdbool.h>
     42#include <inet/addr.h>
    4243#include <inet/iplink.h>
    4344#include <ipc/loc.h>
     
    6162        link_t client_list;
    6263} inetping_client_t;
    63 
    64 /** Host address */
    65 typedef struct {
    66         uint32_t ipv4;
    67 } inet_addr_t;
    68 
    69 /** Network address */
    70 typedef struct {
    71         /** Address */
    72         uint32_t ipv4;
    73         /** Number of valid bits in @c ipv4 */
    74         int bits;
    75 } inet_naddr_t;
    7664
    7765/** Address object info */
  • uspace/srv/net/udp/assoc.c

    rd120133 r192565b  
    279279
    280280        fibril_mutex_lock(&assoc->lock);
    281         while (list_empty(&assoc->rcv_queue)) {
     281        while (list_empty(&assoc->rcv_queue) && !assoc->reset) {
    282282                log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - waiting");
    283283                fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock);
     284        }
     285
     286        if (assoc->reset) {
     287                log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - association was reset");
     288                fibril_mutex_unlock(&assoc->lock);
     289                return ECONNABORTED;
    284290        }
    285291
     
    323329}
    324330
     331/** Reset association.
     332 *
     333 * This causes any pendingreceive operations to return immediately with
     334 * UDP_ERESET.
     335 */
     336void udp_assoc_reset(udp_assoc_t *assoc)
     337{
     338        fibril_mutex_lock(&assoc->lock);
     339        assoc->reset = true;
     340        fibril_condvar_broadcast(&assoc->rcv_queue_cv);
     341        fibril_mutex_unlock(&assoc->lock);
     342}
     343
    325344static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp,
    326345    udp_msg_t *msg)
  • uspace/srv/net/udp/assoc.h

    rd120133 r192565b  
    5151extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, udp_sock_t *);
    5252extern void udp_assoc_received(udp_sockpair_t *, udp_msg_t *);
    53 
     53extern void udp_assoc_reset(udp_assoc_t *);
    5454
    5555#endif
  • uspace/srv/net/udp/sock.c

    rd120133 r192565b  
    537537        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close()");
    538538        int socket_id = SOCKET_GET_SOCKET_ID(call);
    539        
     539
     540        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - find core");
    540541        socket_core_t *sock_core =
    541542            socket_cores_find(&client->sockets, socket_id);
    542543        if (sock_core == NULL) {
     544        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - core not found");
    543545                async_answer_0(callid, ENOTSOCK);
    544546                return;
    545547        }
    546        
     548
     549        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - spec data");
    547550        udp_sockdata_t *socket =
    548551            (udp_sockdata_t *) sock_core->specific_data;
     552        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - lock socket");
    549553        fibril_mutex_lock(&socket->lock);
    550        
     554
     555        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - lock socket buffer");
     556        fibril_mutex_lock(&socket->recv_buffer_lock);
     557        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - set socket->sock_core = NULL");
     558        socket->sock_core = NULL;
     559        fibril_mutex_unlock(&socket->recv_buffer_lock);
     560
     561        udp_uc_reset(socket->assoc);
     562
    551563        int rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock,
    552564            udp_free_sock_data);
    553565        if (rc != EOK) {
     566                log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - socket_destroy failed");
    554567                fibril_mutex_unlock(&socket->lock);
    555568                async_answer_0(callid, rc);
    556569                return;
    557570        }
    558        
     571
     572        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - broadcast recv_buffer_cv");
     573        fibril_condvar_broadcast(&socket->recv_buffer_cv);
     574
    559575        fibril_mutex_unlock(&socket->lock);
    560576        async_answer_0(callid, EOK);
     
    582598        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril()");
    583599
     600        fibril_mutex_lock(&sock->recv_buffer_lock);
     601
    584602        while (true) {
    585603                log_msg(LOG_DEFAULT, LVL_DEBUG, "[] wait for rcv buffer empty()");
    586                 fibril_mutex_lock(&sock->recv_buffer_lock);
    587                 while (sock->recv_buffer_used != 0) {
     604                while (sock->recv_buffer_used != 0 && sock->sock_core != NULL) {
    588605                        fibril_condvar_wait(&sock->recv_buffer_cv,
    589606                            &sock->recv_buffer_lock);
    590607                }
    591                
     608
     609                fibril_mutex_unlock(&sock->recv_buffer_lock);
     610
    592611                log_msg(LOG_DEFAULT, LVL_DEBUG, "[] call udp_uc_receive()");
    593612                urc = udp_uc_receive(sock->assoc, sock->recv_buffer,
    594613                    UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock);
     614                fibril_mutex_lock(&sock->recv_buffer_lock);
    595615                sock->recv_error = urc;
    596                
    597                 udp_sock_notify_data(sock->sock_core);
    598                
     616
     617                log_msg(LOG_DEFAULT, LVL_DEBUG, "[] udp_uc_receive -> %d", urc);
     618
     619                if (sock->sock_core != NULL)
     620                        udp_sock_notify_data(sock->sock_core);
     621
    599622                if (urc != UDP_EOK) {
     623                        log_msg(LOG_DEFAULT, LVL_DEBUG, "[] urc != UDP_EOK, break");
    600624                        fibril_condvar_broadcast(&sock->recv_buffer_cv);
    601                         fibril_mutex_unlock(&sock->recv_buffer_lock);
    602                         break;
    603                 }
    604                
     625                        break;
     626                }
     627
    605628                log_msg(LOG_DEFAULT, LVL_DEBUG, "[] got data - broadcast recv_buffer_cv");
    606                
     629
    607630                sock->recv_buffer_used = rcvd;
    608                 fibril_mutex_unlock(&sock->recv_buffer_lock);
    609631                fibril_condvar_broadcast(&sock->recv_buffer_cv);
    610632        }
    611633
     634        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() exited loop");
     635        fibril_mutex_unlock(&sock->recv_buffer_lock);
    612636        udp_uc_destroy(sock->assoc);
     637
     638        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() terminated");
    613639
    614640        return 0;
  • uspace/srv/net/udp/ucall.c

    rd120133 r192565b  
    113113        log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: udp_uc_receive()", assoc->name);
    114114        rc = udp_assoc_recv(assoc, &msg, fsock);
     115        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv -> %d", rc);
    115116        switch (rc) {
     117        case EOK:
     118                break;
     119        case ECONNABORTED:
     120                return UDP_ERESET;
     121        default:
     122                assert(false);
    116123        }
    117124
     
    133140{
    134141        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_destroy()");
     142        udp_assoc_reset(assoc);
    135143        udp_assoc_remove(assoc);
    136144        udp_assoc_delete(assoc);
     145}
     146
     147void udp_uc_reset(udp_assoc_t *assoc)
     148{
     149        udp_assoc_reset(assoc);
    137150}
    138151
  • uspace/srv/net/udp/ucall.h

    rd120133 r192565b  
    4949extern void udp_uc_status(udp_assoc_t *, udp_assoc_status_t *);
    5050extern void udp_uc_destroy(udp_assoc_t *);
     51extern void udp_uc_reset(udp_assoc_t *);
    5152
    5253#endif
  • uspace/srv/net/udp/udp_type.h

    rd120133 r192565b  
    5151        UDP_EUNSPEC,
    5252        /* No route to destination */
    53         UDP_ENOROUTE
     53        UDP_ENOROUTE,
     54        /** Association reset by user */
     55        UDP_ERESET
    5456} udp_error_t;
    5557
     
    119121        udp_sockpair_t ident;
    120122
     123        /** True if association was reset by user */
     124        bool reset;
     125
    121126        /** True if association was deleted by user */
    122127        bool deleted;
  • uspace/srv/ns/task.c

    rd120133 r192565b  
    208208        sysarg_t retval;
    209209        task_exit_t texit;
     210        bool remove = false;
    210211       
    211212        ht_link_t *link = hash_table_find(&task_hash_table, &id);
     
    235236        }
    236237       
    237         hash_table_remove_item(&task_hash_table, link);
     238        remove = true;
    238239        retval = EOK;
    239240       
     
    243244                ipc_answer_2(callid, retval, texit, ht->retval);
    244245        }
     246        if (remove)
     247                hash_table_remove_item(&task_hash_table, link);
    245248}
    246249
Note: See TracChangeset for help on using the changeset viewer.