Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/io.c

    r8ad496d r82582e4  
    4444#include <io/klog.h>
    4545#include <vfs/vfs.h>
    46 #include <vfs/vfs_sess.h>
    4746#include <ipc/devmap.h>
    4847#include <adt/list.h>
    4948#include "../private/io.h"
    50 #include "../private/stdio.h"
    5149
    5250static void _ffillbuf(FILE *stream);
     
    5856        .eof = true,
    5957        .klog = false,
    60         .sess = NULL,
     58        .phone = -1,
    6159        .btype = _IONBF,
    6260        .buf = NULL,
     
    7270        .eof = false,
    7371        .klog = true,
    74         .sess = NULL,
     72        .phone = -1,
    7573        .btype = _IOLBF,
    7674        .buf = NULL,
     
    8684        .eof = false,
    8785        .klog = true,
    88         .sess = NULL,
     86        .phone = -1,
    8987        .btype = _IONBF,
    9088        .buf = NULL,
     
    127125void __stdio_done(void)
    128126{
    129         while (!list_empty(&files)) {
    130                 FILE *file = list_get_instance(list_first(&files), FILE, link);
     127        link_t *link = files.next;
     128       
     129        while (link != &files) {
     130                FILE *file = list_get_instance(link, FILE, link);
    131131                fclose(file);
     132                link = files.next;
    132133        }
    133134}
     
    254255        stream->eof = false;
    255256        stream->klog = false;
    256         stream->sess = NULL;
     257        stream->phone = -1;
    257258        stream->need_sync = false;
    258259        _setvbuf(stream);
     
    276277        stream->eof = false;
    277278        stream->klog = false;
    278         stream->sess = NULL;
     279        stream->phone = -1;
    279280        stream->need_sync = false;
    280281        _setvbuf(stream);
     
    308309        stream->eof = false;
    309310        stream->klog = false;
    310         stream->sess = NULL;
     311        stream->phone = -1;
    311312        stream->need_sync = false;
    312313        _setvbuf(stream);
     
    323324        fflush(stream);
    324325       
    325         if (stream->sess != NULL)
    326                 async_hangup(stream->sess);
     326        if (stream->phone >= 0)
     327                async_hangup(stream->phone);
    327328       
    328329        if (stream->fd >= 0)
     
    714715off64_t ftell(FILE *stream)
    715716{
    716         _fflushbuf(stream);
    717717        return lseek(stream->fd, 0, SEEK_CUR);
    718718}
     
    732732        }
    733733       
    734         if ((stream->fd >= 0) && (stream->need_sync)) {
     734        if (stream->fd >= 0 && stream->need_sync) {
    735735                /**
    736736                 * Better than syncing always, but probably still not the
     
    770770}
    771771
    772 async_sess_t *fsession(exch_mgmt_t mgmt, FILE *stream)
     772int fphone(FILE *stream)
    773773{
    774774        if (stream->fd >= 0) {
    775                 if (stream->sess == NULL)
    776                         stream->sess = fd_session(mgmt, stream->fd);
    777                
    778                 return stream->sess;
    779         }
    780        
    781         return NULL;
     775                if (stream->phone < 0)
     776                        stream->phone = fd_phone(stream->fd);
     777               
     778                return stream->phone;
     779        }
     780       
     781        return -1;
    782782}
    783783
Note: See TracChangeset for help on using the changeset viewer.